Delete IF !


Posted by Stephen on January 31, 2002 3:00 PM

Hiya Board,

I would like to delete a row if there is a numerical value or text in a cell.
ie - If cell A5 is non-blank delete row 5

Is this possible?

Kind regards

Stephen

Posted by Gary Hewitt-Long on January 31, 2002 4:06 PM

You didn't supply much information about your problem. Did you want to just check the active cell? Look for blank cells in a specific column? or search out different values?

The first one below deletes active cells row if activecell is blank and the second iterates through ten rows from the activecell.

Sub DeleteBlank()
'Deletes entire row if active cell is blank
If ActiveCell.Value = "" Then

ActiveCell.EntireRow.Select
Selection.Delete
End If

End Sub

Sub DeleteBlankIterate()

For i = 1 To 10 ' Moves through ten rows

If ActiveCell.Value = "" Then

ActiveCell.EntireRow.Select
Selection.Delete
End If
ActiveCell.Offset(RowOffset:=1).Select

Next i

End Sub


Gary Hewitt-Long



Posted by Stephen on January 31, 2002 4:16 PM

Gary,
I recieve an excel report every 24hrs
If there is any info (it could be numerical or text)in any cells on column A,
Then that row of info is of no use to me and I have to manually delete that particular row,
The report is usually 200 rows in size and I delete approximately 15-20 rows every day.
Hope this makes sense

Kind Regards

Stephen.