View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan[_2_] Rowan[_2_] is offline
external usenet poster
 
Posts: 226
Default Macro that deletes certain rows and not others

Try something like this (save your data before testing). This tests each used
cell in Column A and deletes the entire row if that cell is empty or contains
numeric data.

Sub DelRows()

Dim endRow As Long
Dim counter As Long

endRow = Cells(Rows.Count, 1).End(xlUp).Row

For counter = endRow To 1 Step -1
If IsNumeric(Cells(counter, 1).Value) Or _
IsEmpty(Cells(counter, 1).Value) Then
Cells(counter, 1).EntireRow.Delete
End If
Next counter

End Sub

Hope this helps
Rowan

"Roger" wrote:

I would like to test the following which are in about 15 rows

if cell contains any kind of text then go to next row as don't want to
delete rows
with text in them
exit if
else - this covers blanks cells and cells with numbers in them
delete row

Repeat until done about 15 times

Any suggestions would be greatly appreciated.

Roger