Hi ,
I want to loop through my columns and hide all columns wherethe total value is 0.
The column range is (A:AEN) & the data begins from row 4 – to last row ( Lastrow is never the same and will always be based on last cell populated on columnA)
The columns can contain text, dates, numeric , blanks and zero’s(0) .
I would like the code to loop through each column and if thetotal equals zero(0) then hide the column , if the total is blank it is ok to not behidden.
I have the below code but it is not running and causing myexcel to restart.
Any help with this is greatly appreciated
Thanks,
Sub exa()
Dim MyCell As Range, MyRange AsRange
Set MyRange = Range("A:AEN")
For Each MyCell In MyRange
If MyCell.Value < 1 OrMyCell.Value = "" Then
MyCell.EntireColumn.Hidden = True
End If
Next MyCell
End Sub
I want to loop through my columns and hide all columns wherethe total value is 0.
The column range is (A:AEN) & the data begins from row 4 – to last row ( Lastrow is never the same and will always be based on last cell populated on columnA)
The columns can contain text, dates, numeric , blanks and zero’s(0) .
I would like the code to loop through each column and if thetotal equals zero(0) then hide the column , if the total is blank it is ok to not behidden.
I have the below code but it is not running and causing myexcel to restart.
Any help with this is greatly appreciated
Thanks,
Sub exa()
Dim MyCell As Range, MyRange AsRange
Set MyRange = Range("A:AEN")
For Each MyCell In MyRange
If MyCell.Value < 1 OrMyCell.Value = "" Then
MyCell.EntireColumn.Hidden = True
End If
Next MyCell
End Sub