I'm trying to cycle through a handful of ranges to insert new range names based on the name of the current tab.
The string variables work. The re-positioning works. But my code inserts the first range name in the very last position. It does not insert any other name.
Can anybody tell me what I'm doing wrong?
[vba]Dim ThisTab As String
ThisTab = Range("AK1").Value
Dim n As Integer
n = 1 'cycles through to 5
Dim NameMe As String
Dim Refers As String
NameMe = ThisTab & n & "_"
Refers = ThisTab & "!R3C29"
Application.Goto Reference:=Refers
ActiveWorkbook.Names.Add Name:=NameMe, RefersToR1C1:=ActiveCell
'these don't work either:
'ActiveWorkbook.Names.Add Name:=NameMe, RefersToR1C1:= "=" & ActiveCell
'ActiveWorkbook.Names.Add Name:=NameMe, RefersToR1C1:= "=" & Refers
ActiveWorkbook.Names(NameMe).Comment = ""
[/vba]