title: Running total loop within loop in vba
body: <p>I'm trying to make my loop at the bottom increase the value m by m each time. For example if m = .002, I want it to increase by .002 for each cell from week_start to 53. I tried to do that with my &quot;decrease&quot; variable.</p>
  <p>Let me know if you know how to make a loop add on to itself with each iteration but just for my variable m.</p>
  <p>Thanks!</p>
  <pre><code>Sub decrease_projections()
  Dim pd As Worksheet
  Dim p As Double
  Dim week_start As Integer
  
  Set pd = Worksheets(&quot;CSD_Proj_Data&quot;)
  
  'clear contents for new values
  pd.Range(&quot;R2:R53&quot;).ClearContents
  
  'reset projected values
  For i = 11 To 53 Step 1
  
  pd.Cells(i, 18) = pd.Cells(i + 253, 4)
  
  Next i
  
  'get input
  p = Val(InputBox(&quot;Enter percentage to decrease projections over time gradually.&quot;, &quot;Decrease Projections&quot;, (0))) / 100
  w = Val(InputBox(&quot;Enter week to begin decrease.&quot;, &quot;Decrease Projections&quot;))
  
  w = Trim(w)
  
  pd.Range(&quot;z1&quot;) = w
  
  week_start = pd.Range(&quot;AA1&quot;)
  
  'calculate percentage loss
  m = p / 30
  
  'for loop to calculate decreased sales projections
      
  For i = week_start To 53 Step 1
  
      decrease = m * (53 - week_start)
      d = pd.Cells(i, 18) * (1 - decrease)
      pd.Cells(i, 18) = d
              
  Next i
  
  'pd.PivotTables(&quot;PivotTable1&quot;).PivotCache.Refresh
  
  End Sub
  </code></pre>