cmefly
Well-known Member
- Joined
- May 13, 2003
- Messages
- 683
hi,
i'm trying to make list names for a bunch of columns on one sheet.
here is the code i have but it's giving me an error...
the name for each list is found in A1, B1, C1, etc. and the range for each list is cells 2:150 for each column.
the name of the worksheet is called LISTS.
any help would be greatly appreciated.
thanks!
Sub makingnames()
Dim columnCount As Integer
Dim i As Integer
Dim listname As String
Dim firstcell As Range
Dim lastcell As Range
Sheets("Lists").Select
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
columnCount = Selection.Columns.Count
For i = 1 To columnCount
listname = Cells(1, i)
firstcell = Cells(2, i)
lastcell = Cells(150, i)
Sheets("Lists").Names.Add Name:=listname.Text, RefersTo:=Sheets("Lists").Range(firstcell, lastcell)
Next i
End Sub
i'm trying to make list names for a bunch of columns on one sheet.
here is the code i have but it's giving me an error...
the name for each list is found in A1, B1, C1, etc. and the range for each list is cells 2:150 for each column.
the name of the worksheet is called LISTS.
any help would be greatly appreciated.
thanks!
Sub makingnames()
Dim columnCount As Integer
Dim i As Integer
Dim listname As String
Dim firstcell As Range
Dim lastcell As Range
Sheets("Lists").Select
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
columnCount = Selection.Columns.Count
For i = 1 To columnCount
listname = Cells(1, i)
firstcell = Cells(2, i)
lastcell = Cells(150, i)
Sheets("Lists").Names.Add Name:=listname.Text, RefersTo:=Sheets("Lists").Range(firstcell, lastcell)
Next i
End Sub