title: Find column number with merged cells vba
body: <p>I would like to find the column with a specific header in a table where almost all the headers are merged. Here is an example with dummy data of what my table looks like:</p>
  
  <p><a href="https://i.stack.imgur.com/NmCvo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NmCvo.png" alt="Table with headers merged"></a></p>
  
  <p>I have tried either looking in row 1 and 2 (range <code>A1:XFD1</code> and <code>A2:XFD2</code>), but it seems that vba cannot find the column I am looking for:</p>
  
  <pre><code>Sub getColumn()
  Dim ColNum As Integer
  On Error Resume Next
  ColNum = Workbooks(ActiveWorkbook.Name).Worksheets("Data").Range("A1:XFD1").Find(What:="Unit Cost", LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False).Column
  MsgBox ("Column number is: " &amp; ColNum)
  End Sub
  </code></pre>
  
  <p>Thank you.</p>