Skip to content

Instantly share code, notes, and snippets.

@aparnachaudhary
Created June 15, 2012 12:45
Show Gist options
  • Save aparnachaudhary/2936303 to your computer and use it in GitHub Desktop.
Save aparnachaudhary/2936303 to your computer and use it in GitHub Desktop.
Delete Empty Columns Excel
Sub DelCol()
'
' DelCol Macro
'
'
Dim wb As Workbook
Dim nLastCol As Long, i As Long
Set wb = ThisWorkbook
With wb.Worksheets(1)
nLastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
For i = nLastCol To 1 Step -1
If .Cells(.Rows.Count, i).End(xlUp).Row = 1 Then
.Columns(i).EntireColumn.Delete
End If
Next i
End With
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment