View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default finding empty rows and deleting

Ryan

Delete entire rows based on blanks in your selected column.

Public Sub DeleteRowOnCell()
''delete any row that has a blank in selected column(s)
Set coltocheck = Application.InputBox(prompt:= _
"Select A Column", Type:=8)
' On Error Resume Next
coltocheck.SpecialCells(xlCellTypeBlanks).EntireRo w.Delete
ActiveSheet.UsedRange
End Sub

Assuming entire row has to be blank.

Sub DeleteEmptyRows()
''only if entire row is blank
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False
For R = LastRow To 1 Step -1
If Application.CountA(Rows(R)) = 0 Then Rows(R).Delete
Next R
End Sub

Gord Dibben Excel MVP

On Wed, 21 Apr 2004 21:01:17 -0700, "Ryan"
wrote:

I have range of data that varies. The data has empty rows of data. I need to find the empty rows and delete them. Need help creating VBA code to do this.