Multiple Dynamic Named Ranges across Columns
On Monday, July 30, 2012 6:17:45 PM UTC-5, Steve wrote:
Hi all. I have been using the following formula to create dynamic named ranges:
=OFFSET(Sheet1!$A$2,0,0,COUNTA(Sheet1!$A:$A),1)
Where A1 is the column header of the data to be included in the named range.
Now I need to create dynamic named ranges from Column A thru Column CK. Is there a way to do this with code so I don't have to manually create each one? The data in row 1 is what I would like the name of the range to be.
Thanks in advance!
Should do it
Sub MakeColumnDefinedNamesSAS()
Dim i As Long
Dim lr As Long
For i = 1 To 89
lr = Cells(Rows.Count, i).End(xlUp).Row
Range(Cells(1, i), Cells(lr, i)).Name = "col" & i
Next i
End Sub
|