Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Hide and Unhide Columns

0

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

Answer
Discuss

Discussion

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: 1989) Sep 26, '16 at 12:10 pm
Add to Discussion

Answers

0

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}.

Discuss


Answer the Question

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