Delete Row if text or empty
Oops!
Ron's reply is the perfect answer Mine was rubbish.
Peter
"PeterAtherton" wrote:
"Terri Miller" wrote:
I have been going through past posts, and they are very helpful. However,
most of them speak to deleting rows with specific data or numbers. I would
like to write a macro that delets all rows in which column A is empty or has
anything other than a date format i.e. dd/mm/yy. Some cells have the text
"DATE", some have "___", some are empty, etc.
Thanks
Terri
I'd copy the data to a new sheet before running this.
Sub test()
Dim r, nr, col, ncol, c
Application.ScreenUpdating = False
Selection.SpecialCells(xlCellTypeLastCell).Select
nr = ActiveCell.Row
'test format of each cell
For r = 1 To nr
Cells(r, 1).Select
If ActiveCell.NumberFormat < "dd/mm/yy" _
Or IsEmpty(ActiveCell) _
Or Not Application.IsNumber(ActiveCell) Then
ActiveCell.EntireRow.Delete
End If
Next
Application.ScreenUpdating = True
End Sub
Peter Atherton
|