How to automatically hide columns containing no data

jcggriff

New Member
Joined
Oct 17, 2002
Messages
5
I have a workbook with 73 columns. I have a formula in each cell in row 2 that enters the word HIDE in the cell if there is no data in the column.

How do I create a Macro or other solution to find the word HIDE in row 2 and then hide that column? I do not want to delete the columns I just need to hide them if they don't contain any data. The data in the columns will change each month.

I am using Excel 2002 and Windows 2000

Thanks for any suggestions.

JCGGRIFF
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
WELCOME TO THE BOARD!

This worked for me:

<font face=Courier New><SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Sub</SPAN> Worksheet_Calculate()
<SPAN style="color:darkblue">Dim</SPAN> ThisCell <SPAN style="color:darkblue">As</SPAN> Range
    <SPAN style="color:darkblue">For</SPAN> <SPAN style="color:darkblue">Each</SPAN> ThisCell <SPAN style="color:darkblue">In</SPAN> Range("A2:BT2")
        <SPAN style="color:darkblue">If</SPAN> ThisCell.Value = "HIDE" <SPAN style="color:darkblue">Then</SPAN>
            ThisCell.EntireColumn.Hidden = <SPAN style="color:darkblue">True</SPAN>
        <SPAN style="color:darkblue">Else</SPAN>
            ThisCell.EntireColumn.Hidden = <SPAN style="color:darkblue">False</SPAN>
        <SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
    <SPAN style="color:darkblue">Next</SPAN> ThisCell
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN></FONT>
 
Upvote 0
Thanks Phantom1975

I will try your solution. It will save me a huge amount of time.

Thanks Again,

jcggriff
 
Upvote 0

Forum statistics

Threads
1,214,787
Messages
6,121,565
Members
449,038
Latest member
Guest1337

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