zombiemaster
Board Regular
- Joined
- Oct 27, 2009
- Messages
- 241
Hi, all…
I recently inherited a daily report - the data each day has varying number of rows, but always the same number of columns.
The instructions I received include running a macro to set up a number of pivot tables, but first we have to manually name two ranges (the first range is the entire data, the second range is only the data in column “J”).
I thought I could include the naming of the ranges in the VBA to avoid the manual aspect, but am having trouble. I was trying to use the endRow$ feature but I’m getting an error…can someone pick this apart and see what I’ve done wrong? Or is endRow$ not the best way to do this after all?
Thanks for your help as always!
~ZM~
I recently inherited a daily report - the data each day has varying number of rows, but always the same number of columns.
The instructions I received include running a macro to set up a number of pivot tables, but first we have to manually name two ranges (the first range is the entire data, the second range is only the data in column “J”).
I thought I could include the naming of the ranges in the VBA to avoid the manual aspect, but am having trouble. I was trying to use the endRow$ feature but I’m getting an error…can someone pick this apart and see what I’ve done wrong? Or is endRow$ not the best way to do this after all?
Thanks for your help as always!
~ZM~
Code:
Sub NamingRanges()
'
' NamingRanges Macro
'
' set endRow
Range("A70000").Select
Selection.End(xlUp).Select
endRow$ = ActiveCell.Row
Range("A1:AB" + endRow$).Select
ActiveWorkbook.Names.Add Name:="Sales_Reporting_Region"
Range("J1:AB" + endRow$).Select
ActiveWorkbook.Names.Add Name:="Multi_Life_Name"
Range("A1").Select
End Sub