Hide a column when cell 12 that row is empty

StanAalbers

Board Regular
Joined
Feb 5, 2008
Messages
51
Hello there,

I have browsed the forum, but haven't found an answer yet for my challenge:

I have a sheet where the data starts in row 12. Whenever the value in that cell (a12, b12, c12, and so forth) is zero, I would like the column to be hidden.

I would like to have it in VBA, since this is a template with 84 columns across that is populated with different analyses every time.

Thanks in advance for your assistance.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hello there,

I have browsed the forum, but haven't found an answer yet for my challenge:

I have a sheet where the data starts in row 12. Whenever the value in that cell (a12, b12, c12, and so forth) is zero, I would like the column to be hidden.

I would like to have it in VBA, since this is a template with 84 columns across that is populated with different analyses every time.

Thanks in advance for your assistance.

Code:
Sub Hide_Columns()
Dim cell As Range
For Each cell In Range("A12:CF12")
If cell.Value = "0" Then
cell.EntireColumn.Hidden = True
End If
Next
End Sub

& to unhide;

Code:
Sub UnHide_Columns()
Columns("A:CF").Select
Selection.EntireColumn.Hidden = False
End Sub

Rgds
Richard
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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