Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |