So maybe another way:

When i run macro with loop, loop will be take every date from:


Jun 7, 2013
Jun 6, 2013
Jun 5, 2013
Jun 4, 2013
Jun 3, 2013
May 31, 2013
May 30, 2013
May 29, 2013
May 28, 2013
May 24, 2013
May 23, 2013
May 22, 2013
May 21, 2013
May 20, 2013
May 17, 2013
May 16, 2013
May 15, 2013
May 14, 2013
May 13, 2013
May 10, 2013
May 9, 2013
May 8, 2013

when meet empty cells loop will stop. And now the most important thing. For example loop take cell B44 ''30 MAY'' so i want to:

1) In sheet "dzienne st zwrotu" macro will calculate 20 average for day -1 from cell B44 ''30 MAY'' (look above) so average for 20 last days -1 = prices from May 29, 2013 to May 1, 2013 < for all stokcs xlu and rest of all. All results will calculate in cells C75 ( i think it is not necessary to explain that) you see formula.
2) excel in sheet VAR take calculate formula see cells C13 C14
3) next step is a to calculate number of shares cells C7 etc for all stocks. Excel take C11 / Adj Close*(again day -1, so 29MAY) from (in this example) DUK sheet same for rest stock and XLU in cell H24.
4) Now open and close price cells C8 and C9, excel take from stocks sheet for example DUK. Take open and close price for current day, so in this example it will be 30 MAY
5) Now solver: when i click "licz" solver dividend cpital from C1 for each stock, Cells C11 etc are the changing cells by solver to max cell C19 (=SUM(C15:AG15).
6) and i see the result in cell J30

I hope u understand what i mean.