title: How to make VBA code run faster when looping through 10,000 cells?
body: <pre><code>Sub GMC()  
      strike = 100
      cap = 120
      part = 3.25
      KO = 60
  
      For i = 1 To 1000
          exp(i) = Worksheets(&quot;Speeder premium&quot;).Cells(i + 1, 32)
          If exp(i) &gt;= cap Then
              cash = strike + (part * (cap - strike))
          ElseIf exp(i) &gt;= strike And exp(i) &lt; cap Then
              cash = strike + (part * (exp(i) - strike))
          ElseIf exp(i) &lt; strike And exp(i) &gt;= KO Then
              cash = strike
          ElseIf exp(i) &lt; strike And exp(i) &lt; KO Then
              cash = exp(i)
          End If
          
          Worksheets(&quot;Speeder premium&quot;).Cells(i + 1, 33) = cash
      Next i
  End Sub
  </code></pre>
  <p>So right now I'm repeating the below code for 1000 repetitions but ideally would like to do so for 10,000. I tried doing this with 10,000 and it is very slow and takes too long to process. How do I make the code faster and more efficient?</p>