title: Type Mismatch Error Excel VBA - Looping through each column of Used Range
body: <p>I have an excel spreadsheet with a title row at the top.  I am trying to log the column number of each cell in the top row of my excel spreadsheet (title row) that matches a certain string such as "Recommended Action 1"</p>
  
  <pre><code>For Each c In Worksheets("Cost Estimates").Range(Cells(1, 1), Cells(totalRows, totalCols))
      If c.Value = "Recommended Action 1" Then
          recAct1 = c.Column
          Debug.Print CStr(recAct1)
      ElseIf c.Value = "Recommended Action 2" Then
          recAct2 = c.Column
      ElseIf c.Value = "Recommended Action 3" Then
          recAct3 = c.Column
      End If
  Next
  </code></pre>
  
  <p>Where recAct holds the column number and totalRows and totalCols are the total number of rows and columns (respectively on the spreadsheet).</p>
  
  <p>I keep receiving a 'Type Mismatch' error for:</p>
  
  <pre><code>If c.Value = "Recommended Action 1" Then
  </code></pre>
  
  <p>I put my cursor over the c value during this error and I get an 'Error 2023' message.</p>
  
  <p>I suspected that it was because c was a column number and not an actual range address. I think this error is caused by the fact that I do not know what type of variable 'c' is actually returning -- I thought it was a range object.</p>