Archive of Mr Excel Message Board
Can someone help with a macro or suggestion on how to automate deleting blank columns in an excel sheet. The blank columns may not always be in the same place...
Thanks tons!

| Check out our Excel VBA Resources | ||||
![]() |
![]() |
![]() |
![]() |
![]() |
Here is such a macro:
Sub DelEmptyCols()
' Deletes all empty columns on the active worksheet
Dim iCol As Integer
With ActiveSheet.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).Delete
End If
Next iCol
End With
End Sub
Happy computing.
Damon
