This will hide all columns where there is a value of 0 in the first row:
Code:
Sub Macro1()
Dim i As Long
Application.ScreenUpdating = False
For i = Cells(1, Columns.Count).End(xlToLeft).Column To 1 Step -1
If Cells(1, i) = 0 Then Cells(1, i).EntireColumn.Hidden = True
Next i
Application.ScreenUpdating = True
End Sub
This will hide all columns where there is a value of 0 in the first row:
Code:
Sub Macro1()
Dim i As Long
Application.ScreenUpdating = False
For i = Cells(1, Columns.Count).End(xlToLeft).Column To 1 Step -1
If Cells(1, i) = 0 Then Cells(1, i).EntireColumn.Hidden = True
Next i
Application.ScreenUpdating = True
End Sub
Perfect, except how do I have it unhide when its not zero. Will be assigning the macro to a button so every time I hit the button it hides all 0 and unhides everything else??
Perfect, except how do I have it unhide when its not zero. Will be assigning the macro to a button so every time I hit the button it hides all 0 and unhides everything else??
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.