LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default I want to make one loop

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
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Loop Function unable to loop Junior728 Excel Programming 1 July 28th 05 10:23 AM
How to Make a Loop count by 1% not 1 MichaelC Excel Programming 8 June 12th 05 02:04 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
Help with macro to make it loop through coloums R Krishna Excel Programming 0 July 29th 03 04:54 PM


All times are GMT +1. The time now is 08:12 PM.

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"