title: Excel VBA ElseIf query
body: <p>The following little piece of vba returns the required value in cell B2. I thought by changing the Range to ("A:A") and ("B:B") I could get it to run through an entire spreadsheet. However it fails to run when I try this. The full list has 15 countries so an IF function copied down column B won't work.
  Any help would be much appreciated. 
  Thanks in advance.</p>
  
  <pre><code>    Sub test()
  
      Dim Country As String, ID As Integer
      Country = Range("A2").Value
  
      If Country = "France" Then
          ID = 1
      ElseIf Country = "Germany" Then
          ID = 2
      ElseIf Country = "Spain" Then
          ID = 3
      ElseIf Country = "Italy" Then
          ID = 4
      Else
          Code = 0
      End If
  
      Range("B2").Value = ID
  
      End sub
  </code></pre>