title: Automatic Execution in response to cell value change
body: <p>I know the code probably isn't very good but I'm still learning VBA. </p>
  
  <p>I've created a worksheet that organizes my college course list but I'm trying to make it so that the code executes automatically when I change a value in the first two columns. </p>
  
  <p>An "x" in the first column selects that as a completed course which subtracts the credit hours for that class from the total hours required. An "S" and some number in the second column denotes a semester and sums up the credit hours to be taken per semester, for example, if I enter "S1" next to "Study and Careers in Engineering", then it will take that 1 credit hour for that class and add it to the total amount of hours for the entire semester.</p>
  
  <p>The two codes are completely independent of each other. </p>
  
  <p>Screenshot of worksheet:
  <a href="http://i.imgur.com/G850X.png" rel="nofollow">http://i.imgur.com/G850X.png</a></p>
  
  <p>Code:</p>
  
  <pre><code>Private Sub Calculations()
  
      Dim creditsLeft As Integer creditsLeft = 130
  
      For i = 3 To 43
          If Cells(i, 1).Value = "x" Then creditsLeft = (creditsLeft - Cells(i, 8)) Next i
  
      Range("J3").Value = creditsLeft
  
  
      Dim S1creds, S2creds, S3creds, S4creds, S5creds, S6creds As Integer
  
      For i = 3 To 43
          If Cells(i, 2).Value = "S1" Then S1creds = (S1creds + Cells(i, 8))
          If Cells(i, 2).Value = "S2" Then S2creds = (S2creds + Cells(i, 8))
          If Cells(i, 2).Value = "S3" Then S3creds = (S3creds + Cells(i, 8))
          If Cells(i, 2).Value = "S4" Then S4creds = (S4creds + Cells(i, 8))
          If Cells(i, 2).Value = "S5" Then S5creds = (S5creds + Cells(i, 8))
          If Cells(i, 2).Value = "S6" Then S6creds = (S6creds + Cells(i, 8)) 
      Next i
  
      Range("J9").Value = "Sem 1 Hrs: " 
      Range("J10").Value = "Sem 2 Hrs: "
      Range("J11").Value = "Sem 3 Hrs: " 
      Range("J12").Value = "Sem 4 Hrs: "
      Range("J13").Value = "Sem 5 Hrs: " 
      Range("J14").Value = "Sem 6 Hrs: "
  
      Range("K9").Value = S1creds 
      Range("K10").Value = S2creds
      Range("K11").Value = S3creds 
      Range("K12").Value = S4creds
      Range("K13").Value = S5creds 
      Range("K14").Value = S6creds
  
      End Sub
  </code></pre>