Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Mike Fogleman wrote
It is OK to set your variables to "0". More curious if it was necessary or not, specifically if they were not, subsequent runs would result in cumulative total. Now I seem to recall variables are reset to 0 each run. Try 1 For..Next loop with an If statement That's the key I was seeking, a strategically placed If statement Workbooks.Open "foodcost" ThisWorkbook.Activate BreakfastTotal = 0 'is this necessary? LunchTotal = 0 'or this? For i = 1 To 4 For some reason, I pictured it placed *after* sheets 1&2 were processed, i.e. If i = 3 Then... If i < 3 Then Sheets(i).Activate t1 = Sheets(i).Rows(2).Find(Date).Offset(Range("Attenda nce").Rows.Count + _ 1, 0).Value Testing revealed following line is indeed necessary If t1 = "" Then t1 = 0 'or this if no non-member ate breakfast? BreakfastTotal = BreakfastTotal + t1 Else Sheets(i).Activate t2 = Sheets(i).Rows(2).Find(Date).Offset(Range("Attenda nce").Rows.Count + _ 1, 0).Value Ditto this If t2 = "" Then t2 = 0 'or this if no non-member ate lunch? LunchTotal = LunchTotal + t2 End If Next Many thanks. -- David |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Loop Function unable to loop | Excel Programming | |||
How to Make a Loop count by 1% not 1 | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming | |||
Help with macro to make it loop through coloums | Excel Programming |