Hi Neil,
The reason your macro runs slow is because you did not turn
off screen updating and turn off calculation. See
Slow Response ...
http://www.mvps.org/dmcritchie/excel/slowresp.htm
But in answer to your question there is a faster way without a
loop and any need to turn off screen updating or calculation
based on the following:.
This macro will delete the empty cell cells in a selection without loops.
Sub DelEmpty()
'Matt Neuburg, PhD
http://www.tidbits.com/matt Aug 3, 1998
Selection.SpecialCells(xlCellTypeBlanks).Delete (xlShiftUp)
End Sub
For your request:
You want to delete the entire row based on column A having empty cells
Sub DelRows_on_EmptyA()
'modified from Matt Neuburg, PhD
http://www.tidbits.com/matt Aug 3, 1998
Columns("A").SpecialCells(xlCellTypeBlanks).Entire Row.Delete (xlShiftUp)
End Sub
Delete Cells/Rows in Range, based on empty cells, or cells with specific values
http://www.mvps.org/dmcritchie/excel/delempty.htm
--
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages:
http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page:
http://www.mvps.org/dmcritchie/excel/search.htm
"Neil" wrote in message ...
Hi,
I have a sheet that I have imported data to, it contains approx 35000 rows
and 7 columns.
10000 of these rows either have a empty cell in column A or has text in it
and I want to delete the entire row
Is there a quicker way then checking each cell in column A and then
deleteing that row.
Sub CheckForNumber()
Dim Lastrow As Long
Dim i As Long
Lastrow = Cells(65536, 1).End(xlUp).Row + 1
For i = Lastrow To 1 Step -1
Range("a" & i).Activate
If Not IsNumeric(ActiveCell.Value) Or IsEmpty(ActiveCell) Then
ActiveCell.EntireRow.Delete
End If
Next
End Sub
I have tried using the following to delete the empty cells
'On Error Resume Next
Columns("A:A").SpecialCells(xlCellTypeBlanks).Enti reRow.Delete
'On Error GoTo 0
but it deletes everything. I have used this in another workbook and it works
OK.
I have also tried filtering the data and only showing the blanks in column A
and then deleting visible rows, but I get an error message that it is too
complex to do.
Thanks in advance
Neil