Find and delete offset loop
Hi Karin
You have to record the first match found then loop until FirstMatch address
= actual match address:
Sub aaa()
Set f = Cells.Find(What:="Chargeable Hours", _
After:=Range("A1"), LookIn:= xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Not f Is Nothing Then
Set FirstMatch = f
Do
If Not IsEmpty(f.Offset(1, 1).Value) Then
f.Offset(1, 0).Delete Shift:=xlUp
End If
Set f = Cells.FindNext(After:=f)
Loop Until f.Address = FirstMatch.Address
End If
End Sub
Regards,
Per
"Karin" skrev i meddelelsen
...
I've got this far, but I don't know how to tell it to stop when it can't
find
it anymore.
Do
Cells.Find(What:="Chargeable Hours", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 1).Select
If Not IsEmpty(ActiveCell.Value) Then
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Delete Shift:=xlUp
End If
"Karin" wrote:
Hi,
I want to find "chargeable hours", then go down 1 row and see if there is
any data in column B -- if there IS data, I want to delete the row. I
want
to loop through the spreadsheet.
Thank you!
|