Worksheet Name RefersTo
Try this instead. Your columns are numeric and should be a letter.
Sub NameBlock()
myLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
myLastCol = ActiveSheet.Cells(2, Columns.Count).End(xlToLeft).Column
Set MyRange = Range(Range("A1"),cells(myLastRow,myLastCol))
ThisWorkbook.Names.Add Name:=Worksheets(1).Name + "_total", _
RefersTo:="=" & MyRange.Address, Visible:=True
End Sub
"caveman.savant" wrote:
I'm trying to select a range of cells and name them based on the name
of the worksheet
Sub NameBlock()
myLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
myLastCol = ActiveSheet.Cells(2, Columns.Count).End(xlToLeft).Column
ThisWorkbook.Names.Add Name:=Worksheets(1).Name + "_total", _
RefersTo:="=$A$2:"&myLastRow, &myLastCol, Visible:=True
End Sub
Something is wrong
|