M
MichaelDavid
Greetings! On page 128 of "Excel 2007 VBA Programmer's Reference" it says
with respect to creating a name which refers to a range: "If you want the
name to be local, you can include a worksheet name: Range("F1:F10").Name =
"Sheet1!Staff" "
In my workbook, BookIssuers.xlsm I have a number of worksheets. The Active
Worksheet is "24Iteration" but it could be any of the worksheets in the
workbook. I tried to make a range on the Active Worksheet local as follows:
First I declared SheetName As String:
Dim SheetName As String
Then, I retrieved the Sheet Name and displayed it as follows:
SheetName = ActiveSheet.Name
MsgBox SheetName
I also tried:
MsgBox ActiveSheet.Name
Both of these MsgBoxes indeed displayed "20Iteration" as expected.
I then tried to name the local range IssuerLabels as follows:
Range("C3:C5").Name = "SheetName!IssuerLabels"
When I run the above instruction, I get:
"Run-time error '1004':
Application-defined or object-defined error"
I then tried running:
Range("C3:C5").Name = "ActiveSheet.Name!IssuerLabels" and got the same error
message.
I then substituted in the actual name of the sheet and ran the instruction:
Range("C3:C5").Name = "24Iteration!IssuerLabels"
which runs without error. Any help or suggestions will be greatly appreciated.
--
May you have a most blessed day!
Sincerely,
Michael Fitzpatrick
with respect to creating a name which refers to a range: "If you want the
name to be local, you can include a worksheet name: Range("F1:F10").Name =
"Sheet1!Staff" "
In my workbook, BookIssuers.xlsm I have a number of worksheets. The Active
Worksheet is "24Iteration" but it could be any of the worksheets in the
workbook. I tried to make a range on the Active Worksheet local as follows:
First I declared SheetName As String:
Dim SheetName As String
Then, I retrieved the Sheet Name and displayed it as follows:
SheetName = ActiveSheet.Name
MsgBox SheetName
I also tried:
MsgBox ActiveSheet.Name
Both of these MsgBoxes indeed displayed "20Iteration" as expected.
I then tried to name the local range IssuerLabels as follows:
Range("C3:C5").Name = "SheetName!IssuerLabels"
When I run the above instruction, I get:
"Run-time error '1004':
Application-defined or object-defined error"
I then tried running:
Range("C3:C5").Name = "ActiveSheet.Name!IssuerLabels" and got the same error
message.
I then substituted in the actual name of the sheet and ran the instruction:
Range("C3:C5").Name = "24Iteration!IssuerLabels"
which runs without error. Any help or suggestions will be greatly appreciated.
--
May you have a most blessed day!
Sincerely,
Michael Fitzpatrick