title: excel VBA formula throws #name error
body: <p>My sub createTrip() creates a new worksheet and a table within it.</p>
  
  <p>It works basically fine, but I use this one function for all the data range cells. The function calculates distances between coordinates in the top rows and the left rows.
  The function itself has <strong>no mistakes</strong>:</p>
  
  <pre><code>=ARCCOS(SIN(E$3*PI()/180)*SIN($C5*PI()/180)+COS(E$3*PI()/180)*COS($C5*PI()/180)*COS(($D5*PI()/180)-(E$4*PI()/180)))*6367.4445
  </code></pre>
  
  <p>(I also tried to add the Worksheets name to it like <code>=ARCCOS(SIN(Processing!E$3*PI()/1...</code> - without any success.)</p>
  
  <p>The problem is, when my sub is done, there will be a <code>#NAME</code>-error in all the data range cells.
  <strong>The error will be removed by clicking into the cell, clicking into the formula-bar and clicking back onto the worksheet - without changing anything.</strong>
  I tried to add some recalculation lines to my sub, but that does not help:</p>
  
  <pre><code>ws.EnableCalculation = False
  ws.EnableCalculation = True
  </code></pre>
  
  <p>What else can I do?</p>
  
  <p>The formula is applied to the cells with VBA like this:</p>
  
  <pre><code>Dim Pro As Worksheet
  Set Pro = ThisWorkbook.Sheets("Processing")
  
     // start for loop (ii)
  
          // if maximum ii is reached:
  
          With Pro
              Set distanceRange = .Range(.Cells(5, 5), .Cells(ii + 6, ii + 6))
          End With
  
          distanceRange.Select
          distanceRange.Formula = "=ARCCOS(SIN(E$3*PI()/180)*SIN($C5*PI()/180)+COS(E$3*PI()/180)*COS($C5*PI()/180)*COS(($D5*PI()/180)-(E$4*PI()/180)))*6367.4445"
  </code></pre>
  
  <p>Thanks for helping here!</p>