Jaymond Flurrie
Well-known Member
- Joined
- Sep 22, 2008
- Messages
- 919
- Office Version
- 365
- Platform
- Windows
I have code like this
which fails (Error 1004, application-defined or object-defined error) on that debug.print row. I have tried it also without the "Sheet1!" prefix, same result. I want the name to be a worksheet level name. I need the comment there. How do I make it work?
So either a different way to assign the given name with a given comment to a given range or just different way to refer are both acceptable answers.
Oh and my Excel is version 16.0.
VBA Code:
Sub testname()
Dim newname As Name
Set newname = Names.Add("Sheet1!Test2", "$Q$1")
newname.Comment = "I'm just testing"
Debug.Print Range("Sheet1!Q1").Name.Name
End Sub
So either a different way to assign the given name with a given comment to a given range or just different way to refer are both acceptable answers.
Oh and my Excel is version 16.0.