View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default do while, do until?

This should work

Do while rTotals.Value < "Monthly Totals"

Sure there is no other character(s) in the cell?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"salgud" wrote in message
...
I've written a program that runs fine. But I want it to stop executing
when
it gets to the line on the source worksheet which has "Monthly Totals" in
column H. I've tried every combination of "Do while", "Do Until", "Loop
While", "Loop Until", equals, does not equal, etc. that I can think of,
but
the macro still executes on the "Montly Totals" row and pastes "Monthly
Totals" into the other worksheet. This seems like it should be simple, but
like most things in VBA, is anything but.

Do while rTotals < "Monthly Totals"
'test for Totals row, skip

Set rTRCell = wsTribalTR.Cells(lTRRow, "A")
sTRID = rTRCell.Value
Set rFoundID = rTribalHist.Find(sTRID, LookIn:=xlValues)
lHistRow = rFoundID.Row + 2
lHistCol = rFoundID.Column
Set rHistStart = wsTribalHist.Cells(lHistRow, lHistCol)
Set rTotals = rTRCell.Offset(0, 7)
If rTotals.Value < "Totals" Then
Set rTRDates = Range(rTotals.Offset(0, -1), rTotals)
rTRDates.Copy Destination:=rHistStart
lHistRow = lHistRow + 1
End If

lTRRow = lTRRow + 1

Loop

End Sub

Is there anyway to get it to loop through the rows but STOP running when
it
sees "Montly Totals"? I guess I could just use an IF statement, but I
thought this would be a good place for a "Do While" or a "Do Until", but
they just don't work!
TIA