How to refer to named ranges & column numbers in VBA?

ajmckenna

Board Regular
Joined
Oct 7, 2002
Messages
145
I want to unhide columns. I have named worksheet cells that calculate the column numbers to unhide. I have named them col_start & col_ end. how do I make this work
say col_start = 3 & col_end=500


Column("col_start:col_end"):EntireColumn.hidden = True

I don't even think this works, can you refer to columns as #'s????
Column("3:500"):EntireColumn.hidden = True

Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
On 2002-10-28 18:03, ajmckenna wrote:
I want to unhide columns. I have named worksheet cells that calculate the column numbers to unhide. I have named them col_start & col_ end. how do I make this work
say col_start = 3 & col_end=500
Column("col_start:col_end"):EntireColumn.hidden = True

I don't even think this works, can you refer to columns as #'s????
Column("3:500"):EntireColumn.hidden = True

Thanks

Columns are named with letters, so, no, you can't do that, at least not directly. You can do, however, something like this:

Range(Cells(1,col_start), Cells(1,col_end)).EntireColumn.Hidden = True
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,210
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top