Summary
An assignment statement, like sTotal = sTotal + sSales
. Adds to a variable, then puts the result back in the variable.
Situation
You are accumulating a value, like a total, or count.
Needs
A variable to be increased/decreased, and a value to add or subtract.
Provides
A variable that has been increased/decreased.
Action
Use an assignment statement, with the variable to be changed on the left and on the right of the =.
Explanation
Usually you find these statements in a loop:
- sTotal = 0
- For sIndex = 1 to sNumberOfRecords
- sSale = rGoatSales.Cells(sIndex, 2)
- sTotal = sTotal + sSale
- Next sIndex
Each time through the loop, another sales value is added.
Where referenced