How to hide and unhide columns based off of a numeric cell value using VBA

tommyboy1019

New Member
Joined
Aug 30, 2018
Messages
11
Hey guys,

This is my first time posting, but I've definitely used the forums for help before.
I need to expand and collapse columns based off of the numerical value in cell A1. And I need to use VBA to do so.
Columns B:Z will expand and collapse. For ex. A1 = 0 then no columns show. A1=10 then B:K will show. If I go back to A1=0 then no columns will show again. If A1=25 then B:Z will show.

Please help, I have very armature knowledge in VBA. Any assistance will be appreciated.

Thanks!
 
I owe you an apology Dave, your code works. You seem to have all the answers. I had my macros disabled like a fool. Thanks for all your help with this. you rock. Quick question though. since I want to hide and unhide based off of cell value, do I need to create 25 cases for each column?

That's very kind of you to say so but I only make suggestions to particular problems that are posted - All the answers are provided by the many who freely contribute to the forum.

Dave
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,225,750
Messages
6,186,805
Members
453,373
Latest member
Ereha

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