Hi I have this macro which I found while searching the board.
it works but I am having trouble changing it to meet my needs.
Sub HideColumns()
Dim i As Integer
On Error Resume Next
Application.ScreenUpdating = False
With Range("d2:Iq2")
.EntireColumn.Hidden = False
For i = 1 To .Columns.Count
If .Columns(i).Value = "" Then
.Columns(i).EntireColumn.Hidden = True
End If
Next i
End With
Application.ScreenUpdating = True
End Sub
seems to work fine in hiding the columns that have nothing in D
but as soon as I change it to my range which is d2:iq40 it stops working properly.
Can anyone help me change it so that it will hide columns only when there is no data in D2:IQ40
it works but I am having trouble changing it to meet my needs.
Sub HideColumns()
Dim i As Integer
On Error Resume Next
Application.ScreenUpdating = False
With Range("d2:Iq2")
.EntireColumn.Hidden = False
For i = 1 To .Columns.Count
If .Columns(i).Value = "" Then
.Columns(i).EntireColumn.Hidden = True
End If
Next i
End With
Application.ScreenUpdating = True
End Sub
seems to work fine in hiding the columns that have nothing in D
but as soon as I change it to my range which is d2:iq40 it stops working properly.
Can anyone help me change it so that it will hide columns only when there is no data in D2:IQ40