我是VBA的新手,我想(1)复制模板并(2)将其放在指定的工作表之前,以及(3)修改其颜色。 (1)和(2)已经很好了,但是我对修改颜色(这是代码的最后3行)有问题,我可以寻求你的帮助来看看..???????????????预先感谢您的帮助,非常感谢!VBA - 复制模板工作表并重命名用户输入的文本并修改标签颜色
子Add_ITS()
Dim wb As Workbook: Set wb = ThisWorkbook
Dim wt As Worksheet: Set wt = wb.Sheets("Data Input-ITS template")
Dim ws As Worksheet: Set ws = wb.Sheets("ITSEnd")
Dim newws As Worksheet, sh As Worksheet, newname
Dim query As Long, xst As Boolean, info As String
xst = False
newname = Application.InputBox("Please Enter the name of the Worksheet")
If newname = "False" Then Exit Sub
For Each sh In wb.Sheets
If sh.Name = newname Then
xst = True: Exit For
End If
Next
If Len(newname) = 0 Or xst = True Then
info = "Sheet name is invalid. Please retry."
GoTo retry
End If
wt.Copy before:=ws: Set newws = ActiveSheet: newws.Name = newname
With wb.newws.Tab
.Color = 6299648
.TintAndShade = 0
End With
End Sub
[?更改使用VBA在Excel选项卡的颜色]的可能的复制(http://stackoverflow.com/questions/12464457/changing-color-of-tabs-in-excel-using -vba) –