title: Excel/VBA - Function to return integer
body: <p>I would like a function to return the index of a column given the rowIndex and a Cell Value:</p>
  
  <pre><code>'Get index of column given a heading name
  Function FindColumnIndex(name As String, rowNumber As Integer) As Integer
      Dim index As Integer
      index = 1
      Dim found As Boolean
      found = False
  
      Do While found = False
          If Cells(rowNumber, index).Value = name Then
              FindColumnIndex = index
              Exit Do
          End If
  
          index = index + 1
      Loop
  
      FindColumnIndex = index
  
  
  End Function
  </code></pre>
  
  <p>I will then assign this to a value:</p>
  
  <pre><code>Dim colIndex As Integer
  colIndex = FindColumnIndex("Physical or Virtual", 2)
  </code></pre>
  
  <p>Problem is this isn't working - and I am sure my function is incorrect - Anyone know what I'm doing wrong?</p>