View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Find and delete offset loop

Give this code a try instead (where I have assumed your "chargeable hours"
text is in Column A)...

Sub RemoveChargeableHours()
Dim X As Long, C As Range, FirstAddress As String
With Worksheets("Sheet1").Columns("A")
Set C = .Find("chargeable hours", LookIn:=xlValues, LookAt:=xlWhole, _
MatchCase:=False, SearchDirection:=xlPrevious)
If Not C Is Nothing Then
FirstAddress = C.Address
Do
If Len(Cells(C.Row + 1, "B")) 0 Then Rows(C.Row + 1).Delete
Set C = .FindNext(C)
X = X + 1
Loop While X < Application.CountIf(Columns("A"), "chargeable hours")
End If
End With
End Sub

--
Rick (MVP - Excel)


"Karin" wrote in message
...
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!