LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default do while, do until?

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"