title: Variables as field names
body: <pre><code>For R = 1 To NRrows
  
      If (RSNonResourceCosts![CostType]) &lt;&gt; "" Then
          CL(1) = CL(1) + 1
          WKS.Cells(199 + R, 1) = (RSNonResourceCosts![CostType])
      End If
  
      If (RSNonResourceCosts![SoftwareCosts]) &lt;&gt; "" Then
          CL(2) = CL(2) + 1
          WKS.Cells(199 + R, 2) = (RSNonResourceCosts![SoftwareCosts])
      End If
  
      RSNonResourceCosts.MoveNext
  
  Next R
  </code></pre>
  
  <p>Attached is a "Cut down" version of the code. I am writing to an Excel spreadsheet to apply Indirect formula. <code>[CostType]</code> and <code>[SoftwareCosts]</code> in the example are constants at the moment. </p>
  
  <p>I want the user to be able to add fields without then having to amend the code. The new field name will be derived from the table. Is it possible to use a field name (not known until the table is modified) between the square brackets?</p>