Reputation: 25
I am putting the final touches on a macro code however the last bit of line I have included is used to delete rows where data in column A is blank. When I have a situation where there would be blank rows it works fine however if there is no need for a row deletion I am having a debugging issue. How can I change my code posted below to work only when there are extra blank rows based on no information in column A and work the same when there is no need for deletion.
Range("A7:A" & LastRow).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Upvotes: 0
Views: 44
Reputation: 4309
Count the blank rows in the range first and if there is then execute the delete code, otherwise just pass:
If Application.WorksheetFunction.CountBlank(Range("A1:A" & LastRow)) > 0 Then
Range("A1:A" & LastRow).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End If
Upvotes: 1