title: Running a calculation function for n number of rows
body: <p>I want to automate a calculation for a measurement data Excel file.</p>
  <p>While I made the function work, I could only figure out how to do that for one row at a time. The calculation is specific to the data on every row.</p>
  <p>I thought I could change the <code>Range(&quot;J3&quot;)</code> value to <code>Range(&quot;J3:J52&quot;)</code> for a capacity of 50 calculations.</p>
  <p>How do I make the function calculate for every row, separately, using the data of said specific row?</p>
  <p>It doesn't matter if it runs for all 50 rows or if I have to figure out some loop function to find how many rows to calculate for, as long as one button press in the end will make the magic happen.</p>
  <p>I have included a screenshot of the sheet for reference, the main calculation is done in Excel, but what this is doing is choosing the correct option out of a few different correction calculations and explaining to the user why.</p>
  <p>I think there are some unnecessary Dim lines at the start but if it runs, I wasn't going to remove them.</p>
  <p><a href="https://i.stack.imgur.com/tHwvV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tHwvV.png" alt="enter image description here" /></a></p>
  <pre class="lang-vb prettyprint-override"><code>'The main function, activated by a simple button Sub'
  Function ISO16032()
  
      'DeltaL Range'
      Dim DeltaL As Range
      Set DeltaL = Range(&quot;F3&quot;)
      'Result is the corrected value in G column'
      Dim Result As Long
      'Note is the calc note in H column'
      Dim Note As String
      'X is the DeltaL between noise and background noise'
      Dim x As Long
      x = Range(&quot;F3&quot;).Value
      
      Select Case Range(&quot;F3&quot;).Value
      
          'No correction when X = &gt; 10'
          Case 10.6 To 200
              Result = Range(&quot;J3&quot;)
              Range(&quot;G3&quot;).Value = Result
              Note = &quot;No correction&quot;
              Range(&quot;H3&quot;).Value = Note
          
          'Correction according to ISO16032 when X = between 4 and 10'
          Case 3.6 To 10.5
              Result = Range(&quot;K3&quot;)
              Range(&quot;G3&quot;).Value = Result
              Note = &quot;Correction per ISO16032&quot;
              Range(&quot;H3&quot;).Value = Note
          
          'Maximal correction value set to 2,2 dB if X &lt; 4'
          Case 0.1 To 3.5
              Result = Range(&quot;L3&quot;)
              Range(&quot;G3&quot;).Value = Result
              Note = &quot;Correction limit set to 2,2 dB&quot;
              Range(&quot;H3&quot;).Value = Note
          
          'If x = &lt; 0, the measurement is invalid'
          Case Else
              Note = &quot;Repeat measurement!&quot;
              Range(&quot;H3&quot;).Value = Note
      
      End Select
  
  End Function
  </code></pre>