As I am sure will become apparent, I am new to Visual Basic.
I'm trying to change the name of an Excel Sheet identified by the value in a particular spreadsheet cell to a name that I get from the user.
I know that Sheets("Sheet2").Name = "NewSheetName" will change the name. Here is my code (the code is called by and ActiveX button):
This gives an error of Run_time error '9': Subscript out of range. The MsgBox tells me that Chr(34) is not getting translated into quotes. And it doesn't look right to me, but I have tried several different ways of formatting the Sheets . . . . line and nothing I have come up with works.
I will greatly appreciate any help you call can give me! And I would love to know of a reference that explains how to plug variables into object property values. I keep getting hung up on this kind of thing.
I'm trying to change the name of an Excel Sheet identified by the value in a particular spreadsheet cell to a name that I get from the user.
I know that Sheets("Sheet2").Name = "NewSheetName" will change the name. Here is my code (the code is called by and ActiveX button):
Code:
Private Sub A9_Click()
Dim SheetName As String
If Range("A9").Interior.Color = 16777215 Then
SheetName = InputBox(Prompt:="Enter Name of Client", _
Title:="ENTER Client NAME", Default:="Client Name here")
MsgBox ("Range(Chr(34)K1Chr(34))")
Sheets(Chr(34)&"Range" &(Chr(34)&"K1"&Chr(34)&)").Name = SheetName
ElseIf Range("A9").Interior.Color = 5880731 Then
Range("A9").Style = "Accent2"
ElseIf Range("A9").Interior.Color = 5066944 Then
Range("A9").Style = "Accent3"
End If
End Sub
I will greatly appreciate any help you call can give me! And I would love to know of a reference that explains how to plug variables into object property values. I keep getting hung up on this kind of thing.