Hide and Unhide Columns


Good morning. 

Okay so I have been trying to acheive this for 3 days now.  I have tried loops etc.  I am very much a VBA novice.  Unfortunately, I have been unable to make this work as required.

I am attaching 2 example Workbooks MasterData.xlsx and WorkingData.xlsm

WorkingData.xlsm needs to have a button that when pressed it will hide all columns in MasterData.xlsx except for the ones where the data in row 4/5 within WorkingData.xlsm match the data in row 1 within MasterData.xlsx

It need to do this irrespective of the sheet labels as they may not always be the same in MasterData.xlsx

I hope this goes somewhat further to explain what I need achieve.

Once again help from anyone would be very much appreciated.

Not sure if the files are going to attach or not.

Kind regards BanburyS



Please try and attach the files again. Edit your question and you will be able to attach them from there by clicking the button that says "Add Files to this Post".
don (rep: 1492) Sep 26, '16 at 12:10 pm
Add to Discussion



Yes - need to see files attached.  But as alternative you could use Groupings to easily hide/unhide columns or rows.  Alternatively, Control + 9 (above keyboard, do NOT use keypad for '9' will Hide ROWS [ Control + Shift + ( ] will unhide rows.   Control + 0 to HIDE Columns [ Control + Shift + ) to UNHIDE].  note the compliment of the '9' key is the '(' {left paren} and the compliment of the '0' is ) {the right paren}.


Answer the Question

You must create an account to use the forum. Create an Account or Login