title: References to another sheet in worksheet created via macro
body: <p>Here I have some question about references. I have a project where I create some work schedule. It is a simple calendar, where in one column i have dates and each row in this column have information about planed work time and real work time. I have created a workbook, where I have configuration data and some button to run worksheets creation process. Each worksheet for one employee. All formulas are inject by macro. Goal is to calculate overtime with some algoritm. To complete this I need to check:</p>
  
  <ol>
  <li>First day of month check if last day of previous month was a work day;</li>
  <li>Last day of month check if first day if next month is a work day;</li>
  </ol>
  
  <p>So I insert some formula by vba worksheet.cell.formula. When formula references to previous sheet, it calculate correctly. But when I use formula with reference to next sheet, got #ARG error. But if I select cell with this formula and press Enter key, it calculates correctly. References were made by sheet name and via cell.address, but same effect.</p>
  
  <p>First step is to add 12 sheets to config Worksheet via</p>
  
  <pre><code>For arkusze = 1 To 12
      SheetName = miesiace(arkusze)
      Set wkbk = ThisWorkbook
      Set wks1 = ThisWorkbook.Worksheets.Add(After:=wkbk.Worksheets(wkbk.Worksheets.Count))
      wks1.Name = SheetName
  Next arkusze
  </code></pre>
  
  <p>Good formula is: <code>=daj50pr_new3(C" &amp; dni + 5 &amp; ":G" &amp; dni + 5 &amp; "," &amp; wkbk.Worksheets(arkusze + 1).Cells(Day(pierw_dzien_mies - TimeValue("01:00:01")) + 5, 4).Address(External:=True) &amp; ",D" &amp; dni + 6)</code></p>
  
  <p>Bad is: <code>=daj50pr_new3(C" &amp; dni + 5 &amp; ":G" &amp; dni + 5 &amp; ",D" &amp; dni + 4 &amp; "," &amp; wkbk.Worksheets(arkusze + 3).Cells(6, 4).Address(External:=True))</code></p>
  
  <p>Finally 12 sheets are moving to final worksheet via<br>
  <code>For Z = 3 To 14
  wkbk.Worksheets(Z).Copy After:=wbNew.Sheets(wbNew.Sheets.Count)
  next Z</code></p>
  
  <p>Worksheet is saving with FileFormat:=52.<br>
  How to solve this? Why references to next sheet produce error?</p>