Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The macro will create named ranges for columns 1 through 50 in Sheet1. Named
ranges will be named as ColumnX, where X is the column number. Sub NameColumns1to50() Dim i As Integer Dim strEntireColumn As String Dim strReferenceCell As String For i = 1 To 50 strReferenceCell = Cells(1, i).Address strEntireColumn = Range(Cells(1, i), Cells(65536, i)).Address ThisWorkbook.Names.Add "Column" & i, "=OFFSET(Sheet1!" & strReferenceCell & ",0,0,COUNTA(Sheet1!" & strEntireColumn & "),1)" Next i End Sub "sancht" wrote: Hi I have an excel sheet with over 50 columns. I was wondering if I could write a macro (i'm a novice programmer) or record one to create name ranges on each column. I am using the offset and count function to name the ranges as I would be adding new rows (to the same columns) every few days. I hope someone cal help me. Thanks, ST |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Storing multiple ranges using a macro | Excel Discussion (Misc queries) | |||
Macro Help (Uppercase multiple ranges?) | Excel Discussion (Misc queries) | |||
How do I record a macro which should work on multiple files ? | Excel Discussion (Misc queries) | |||
Record Macro - Record custom user actions | Excel Programming | |||
Print macro for multiple ranges/sheets | Excel Programming |