Macro to search headings of a column and hide if it contains a word contained in a drop down menu

peterjackson12

New Member
Joined
Dec 6, 2012
Messages
2
Cell A1 contains a drop down menu which contains different headings - so cat dog etc

I have a large spreadsheet, each column is headed with either cat dog etc in row 4

I would like the macro to automatically read what is selected in the drop down cell, and look at each of the headings in row 4, hiding any of the columns that do not match that of the drop down.

And if nothing is selected in the drop down menu I would like all of the spreadsheet to be visible
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
I'll assume you have some kind of dynamic list for your drop down, how is this list defined?

So if the column exists then only hide that column...or hide every column in the list?

If the cell with dropdown is blank then everything is shown?
 
Upvote 0
Thank you for looking at this.

The aim was that if you select cat for example from the drop down list, the macro looks at each column heading and if the heading says cat the column stays, if the heading does not say cat then the column becomes hidden.

So if you want to see just the columns containing cat as the heading you select cat in the drop down menu.

If you want to see just the columns containing dog as the heading you select dog in the drop down menu.

All of the other columns then become hidden.

The list is defined as ColumnHeadings
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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