gpt4 book ai didi

Excel VBA 存储/暗表标签颜色

转载 作者:行者123 更新时间:2023-12-04 21:34:44 26 4
gpt4 key购买 nike

我使用此代码删除事件工作表,然后复制不同的工作表,然后将复制的工作表重命名为与已删除工作表相同的名称,如何更改复制工作表上的工作表选项卡颜色以匹配已删除的工作表。

Dim ShtName As String
Dim ws As Worksheet
Application.DisplayAlerts = False

ShtName = ActiveSheet.NAme
ActiveSheet.Delete

Dim NewSht As Worksheet

Master_Work_Order.Copy After:=ActiveSheet

Set NewSht = ActiveSheet

'set new copied sheet name to Previous ActiveSheet's name
NewSht.NAme = ShtName

最佳答案

使用Sheet.Tab.Color

Sub test()

Dim ShtName As String
Dim ws As Worksheet

Dim oldTabColor

Application.DisplayAlerts = False

ShtName = ActiveSheet.Name

'/ Store Old Tab Color

oldTabColor = ActiveSheet.Tab.Color

ActiveSheet.Delete

Dim NewSht As Worksheet

Master_Work_Order.Copy After:=ActiveSheet

Set NewSht = ActiveSheet

'set new copied sheet name to Previous ActiveSheet's name
NewSht.Name = ShtName


NewSht.Tab.Color = oldTabColor


End Sub

关于Excel VBA 存储/暗表标签颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41642583/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com