title: Looped If/Then Functions in Excel VBA
body: <p>I'm just starting to learn Excel VBA and I'm running into problems with a particular exercise. Given a column of 20 randomly generated integers between 0 and 100 in a column, I want to write a VBA program that writes in the column next to it "pass" if the number is greater than or equal to 50 and "fail" if the number is less than 50. </p>
  
  <p>My approach involved using a looping function from i = 1 to 20 with an If statement for each cell (i,1) which would write pass or fail in (i,2).</p>
  
  <pre><code>Sub CommandButton1_Click()
  'Declare Variables
  Dim score As Integer, result As String, i As Integer
  
  'Setup Loop function, If/Then function
  For i = 1 To 20
      score = Sheet1.Cells(i, 1).Value
      If score &gt;= 60 Then result = "pass"
      Sheet1.Cells(i, 2).Value = result
  Next i
  
  End If
  End Sub
  </code></pre>
  
  <p>Could I get some insight into what I'm doing wrong?</p>
  
  <p>Thanks in advance!</p>