The Solution to Macro Monday Delete Blank Rows and Columns.

Code:
=================

Sub BlankRows()

erw = Sheet1.Cells.SpecialCells(xlCellTypeLastCell).Row
ecl = Sheet1.Cells.SpecialCells(xlCellTypeLastCell).Column

For rw = erw To 1 Step -1
cnt = Application.WorksheetFunction.CountA(Sheet1.Rows(rw))
If cnt = 0 Then
Sheet1.Rows(rw).Delete
End If
Next

For cl = ecl To 1 Step -1
cnt = Application.WorksheetFunction.CountA(Sheet1.Columns(cl))
If cnt = 0 Then
Sheet1.Columns(cl).Delete
End If

Next

End Sub

Chris Terrell

View all posts