View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] aidan.heritage@virgin.net is offline
external usenet poster
 
Posts: 244
Default Macro to Delete a Row

If you look up delete in help, you will find an example that is almost
what you need


This example sorts the data in the first column on Sheet1 and then
deletes rows that contain duplicate data.

Worksheets("Sheet1").Range("A1").Sort _
key1:=Worksheets("Sheet1").Range("A1")
Set currentCell = Worksheets("Sheet1").Range("A1")
Do While Not IsEmpty(currentCell)
Set nextCell = currentCell.Offset(1, 0)
If nextCell.Value = currentCell.Value Then
currentCell.EntireRow.Delete
End If
Set currentCell = nextCell
Loop


The only difference here is the test - this has nextcell.value being
compared to currentcell.value, you simply need to test
currentcell.value for being blank (len for example would do this)