Not sure I understands your problem totaly. Running solver in a loop as I said is no problem:
Sub TestLoop()
Dim cell As Range
For Each cell In Range("B38:B" & Range("B" & Rows.Count).End(xlUp).Row)
SolverOk SetCell:="$C$19", MaxMinVal:=1, ValueOf:="0", ByChange:="$C$11:$AG$11"
SolverSolve UserFinish:=True
Range("J30").Copy
cell.Offset(0, 1).PasteSpecial Paste:=xlPasteValues
Next
Application.CutCopyMode = False
End Sub
This macro will run solver in a loop using range B38 to B59 as the counter and placing the solver result in a cell with an offset of (0, 1). That is loop starts at B38 and the solver result will be placed in a cell on the same row (i.e. row 38) but in a column one position to the right of B38 i.e. C38. The next loop will then use B39 as a counter and result will be placed in C39 and so on.
What I do not understand is the rules for how you change input data to solver. In your example you select May 22 and then you take average from May 21 to April 24??
So what data should solver be given for each change of date in the range B38 to B59?
Alf
Bookmarks