VBA hides/unhides columns based upon pivot table and value

mapatton

New Member
Joined
Feb 27, 2024
Messages
1
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I am not well skilled in VBA so looking for assistance.
I have 2 similar situations:

1.
I have a pivot table that for columns headers are displayed as weeks. IE Week 01 Week 02 Week 03
Needless to say if data hasn't been entered into the source data for Week 04, there is no Week 04 in the pivot table.
Looking for some VBA that will automatically hide all the columns without a Week. I can not base this on values inside the pivot table itself as there may be no data to pivot, but I still have a Week and need to display it.

2. Similar to 1 except this is a PW protected sheet I set up for the owners with direct references to cells in item 1. Needless to say, in the above scenario for Week 04, the owners sheet displays a 0.

Also I would like to embed this in a way that it controls multiple worksheets, but not all. Some of the workbooks have 30+ worksheets in them. There may not be a way to do that without it impacting the entire workbook, so if I need to add the VBA to the desired sheets, so be it.

Thank you
Mark
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

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