I have a spreadsheet that will have column headers. But some of the columns will be empty. I need to determine which columns are empty, minus the column headers, and hide them all. I've tried several things but I'm sure I'm missing something.
Sub HideEmptyCols()
' Deletes all empty columns on the active worksheet
Dim iCol As Integer
Dim wsSheet As Worksheet
For Each wsSheet In Worksheets
wsSheet.Select
With wsSheet.UsedRange
For iCol = .Column + .Columns.Count - 1 To 1 Step -1
If IsEmpty(Cells(65536, iCol)) And IsEmpty(Cells(1, iCol)) Then
If Cells(65536, iCol).End(xlUp).Row = 1 Then Columns(iCol).Hidden = True
MsgBox (iCol)
End If
MsgBox (iCol)
Next iCol
End With
Next wsSheet
End Sub
Bookmarks