JonMo1, Thanks for your interest, The ranges will only ever change by increasing the number of rows.
ChemistB, Here is how I have used your code in my sub routine.
Sub NameRanges()
Dim ws As Worksheet, ShortName As String
For Each ws In Worksheets
ShortName = Left(ws.Name, Len(ws.Name) - 5)
Select Case ShortName
Case Is = "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER", "JANUARY", "FEBRUARY", "MARCH"
'
ActiveWorkbook.Names.Add Name:=ws.Name & "_Table", RefersToR1C1:= _
"= OFFSET(ws.Name!R8C1,0,0,COUNTA(ws.Name!C1)-2,41)"
End Select
Next
End Sub
This does create new ranges with the right names. The RefersTo column in the NamesManager however reads
=Offset(ws.Name!$A$8,0,0,Counta(ws.Name!$A:$A)-2,41)
It looks as though ws.name has been treated like a string rather than a variable. I am going to try:-
RefersToR1C1 = "=Offset(" & ws.Name & "!R8C1,0,0,Counta(" & ws.Name & "!C1)-2,41)"
And that worked! Thanks for your help
John
Bookmarks