PDA

View Full Version : delete blank rows



danthegolfer
10-08-2009, 11:29 PM
hey, im working on a data consolidation project.

i've already written code which consolidates the data off of about 70 worksheets into one worksheet (about 7000 rows worth of data). however, some of those rows are blank. i need to write a piece of code that will go through and delete the blank rows.

im guessing it will be an If-Then statement, but im not sure how to do it. any help is appreciated.

thanks, dan

Bob Phillips
10-09-2009, 04:04 AM
Simplest way


Dim LastRow As Long
Dim i As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = LastRow To 1 Step -1

If Application.CountIf(.Rows(i), "<>") = 0 Then

.Rows(i).Delete
End If
Next i
End With