VBA Hide/UnHide columns

Joined
Feb 20, 2010
Messages
3
Reaction score
0
Hello everyone, I hope you can be of assistance

I am trying to automate a worksheet using VBA to hide unecessary columns when they have no data input, but then unhide them when data is input...

On one worksheet, from row E5 to BA5 will either display a 0 or any text entry linked from another worksheet, I basically want:

  • for individual columns to hide where the 5th row (range E5 to BA5) displays 0
  • for individual columns to unhide when any text entry is displayed in the same 5th row (range E5 to BA5)
The VBA code I have is as follows: Note this hides the columns, but then when I enter new text it doesn't unhide them.

Sub HideColumn()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For a = 0 To 3
If Range("E5").Offset(0, a).Value = "Hide Column" Then Range("E5").Offset(0, a).EntireColumn.Hidden = True
Next a
Application.ScreenUpdating = True


End Sub


Thanks in advance

David
 
Last edited:
Back
Top