VBA to hide/unhide columns on range of protected worksheets if value in row 1 is "1"

Jason44136

New Member
Joined
Jul 8, 2019
Messages
18
Office Version
  1. 365
Platform
  1. Windows
Greetings experts...

I have a workbook with three summary sheets and 31 different sheets (1, 2, 3 …). On my "Setup" sheet, I have a command button that will have a macro assigned. I am trying to write the VBA to hide all columns on sheets 1-31 if the value in row 1 is "1". All sheets are protected, so I know we'd have to have an Unprotect and protect line in the VBA. I tried using some other suggestions from my other threads, but no luck. If the cells that trigger the 1 in row 1 change (and thus the 1 is no longer present)… this should update when the command button is pressed again. It does not need to update automatically. I should note that sheets 1-31 will always be identical with the row 1 value based on the setup sheet.

I would prefer the macro just works without having to use a command button at all, but having the button does not bother me.
 
You're welcome. :)

It is pretty fast as it only deals with the columns on one sheet (as it is activated) and it hides all the 1 columns at once rather than checking columns E:R one at a time.
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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