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 "decrease" variable.
Let me know if you know how to make a loop add on to itself with each iteration but just for my variable m.
Thanks!
Sub decrease_projections()
Dim pd As Worksheet
Dim p As Double
Dim week_start As Integer
Set pd = Worksheets("CSD_Proj_Data")
'clear contents for new values
pd.Range("R2:R53").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("Enter percentage to decrease projections over time gradually.", "Decrease Projections", (0))) / 100
w = Val(InputBox("Enter week to begin decrease.", "Decrease Projections"))
w = Trim(w)
pd.Range("z1") = w
week_start = pd.Range("AA1")
'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("PivotTable1").PivotCache.Refresh
End Sub
Dim loopCount As Longvariable. Initialize it toloopCount = 1before the loop starts, thendecrease = m * (53 - week_start) * loopCountandloopCount = loopCount + 1. This should increase yourdecreasevalue with every iteration of the loop.