我使用此代码删除活动工作表,然后复制另一个工作表,然后将复制的工作表重命名为与已删除的工作表相同,如何更改复制工作表上的工作表选项卡颜色以匹配已删除的工作表。< / p>
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
答案 0 :(得分:4)
使用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