you can use this to name a range. Not sure why wrkSheet is a string as it should be a worksheet object
Dim ws As Worksheet
Dim r As Range
Set ws = Sheets(1)
Set r = ws.Range("A1:B2")
r.Name = "test"
Question
I have searched for a solution but can't seem to find one. If one exists, please point me to it. The question is how do I name a range in VBA.
wrkSheet.Range("A1").Name = "Test"
Works fine but as soon as I change it to
wrkSheet.Range("A1:B2").Name = "Test"
gives me problems. Note, wrkSheet is a worksheet object that is defined earlier.
Thanks
Solution
you can use this to name a range. Not sure why wrkSheet is a string as it should be a worksheet object
Dim ws As Worksheet
Dim r As Range
Set ws = Sheets(1)
Set r = ws.Range("A1:B2")
r.Name = "test"
OTHER TIPS
You're not naming a range there... you giving values to a excel range of cells... To name a range you do
range = wrkSheet.Range("A1:B2").Name
Then you can do range(1,1) = "test"
for example.