IanWallbridge
New Member
- Joined
- Jan 29, 2014
- Messages
- 10
Hi all,
I've often used the following two lines of VBA to name column ranges based on text labels in the first row of a worksheet, and this has always been really useful when manipulating data.
However, in my latest code I need to completely delete some columns, but have realised that - by default - the named ranges start in row 2 and don't include the top (labelled) row.
Can this code be tweaked with some sort of offset so that the label is included? I've tried setting the range in the first line to include row numbers, but this doesn't make any difference.
Hope someone can advise..
I've often used the following two lines of VBA to name column ranges based on text labels in the first row of a worksheet, and this has always been really useful when manipulating data.
Code:
Set rangeToName = Worksheets("Sheet1").Range("A:BZ")
rangeToName.CreateNames Top:=True, Left:=False, Bottom:=False, Right:=False
However, in my latest code I need to completely delete some columns, but have realised that - by default - the named ranges start in row 2 and don't include the top (labelled) row.
Can this code be tweaked with some sort of offset so that the label is included? I've tried setting the range in the first line to include row numbers, but this doesn't make any difference.
Hope someone can advise..