Find/Delete Row and Row Above


Posted by Ed on May 10, 2001 12:19 PM

Is there a macro that can find all cells in one column with #REF! and the row above, select and delete these rows?

Thanks,

Ed

Posted by Dave Hawley on May 10, 2001 12:40 PM


Hi ed

Try this one.


Sub DeleterefRows()
'Written by OzGrid Business Applications
'www.ozgrid.com

Dim rRows As Range
Dim rCells As Integer
Dim i As Integer

Application.ScreenUpdating = False
Set rRows = Selection.EntireColumn

For i = 1 To WorksheetFunction.CountIf(rRows, "#REF!")
rRows.Find(What:="#REF!").Offset _
(-1, 0).Range("A1:A2").EntireRow.Delete
Next i

Set rRows = Nothing
Application.ScreenUpdating = True
End Sub

Dave
OzGrid Business Applications

Posted by Dave Hawley on May 10, 2001 12:42 PM

Forgot to say...

Before running it, just select any cell in the Column you want checked.


Dave

OzGrid Business Applications

Posted by Dave, Do You Ever Sleep? on May 10, 2001 12:49 PM

Hi ed Sub DeleterefRows() 'Written by OzGrid Business Applications 'www.ozgrid.com Dim rRows As Range Dim rCells As Integer Dim i As Integer Application.ScreenUpdating = False Set rRows = Selection.EntireColumn For i = 1 To WorksheetFunction.CountIf(rRows, "#REF!") rRows.Find(What:="#REF!").Offset _ (-1, 0).Range("A1:A2").EntireRow.Delete Next i Set rRows = Nothing Application.ScreenUpdating = True End Sub

Dave


Dave,

This worked great! As always, Thanks for the help! By the way, I might hit you up for some training in the near future.

Thanks again,

Ed

Posted by Dave, Do You Ever Sleep? on May 10, 2001 12:49 PM

Hi ed Sub DeleterefRows() 'Written by OzGrid Business Applications 'www.ozgrid.com Dim rRows As Range Dim rCells As Integer Dim i As Integer Application.ScreenUpdating = False Set rRows = Selection.EntireColumn For i = 1 To WorksheetFunction.CountIf(rRows, "#REF!") rRows.Find(What:="#REF!").Offset _ (-1, 0).Range("A1:A2").EntireRow.Delete Next i Set rRows = Nothing Application.ScreenUpdating = True End Sub

Dave


Dave,

This worked great! As always, Thanks for the help! By the way, I might hit you up for some training in the near future.

Thanks again,

Ed



Posted by Dave Hawley on May 10, 2001 1:12 PM

Ed, LOL! Yeah I do sleep, but I quite often work nights. I guess that is one of the drawbacks living in Oz and running an E-Business.

Look forward to hearing from you.

DaveOzGrid Business Applications