title: Excel VBA Get values of merged cells
body: <p>I've found simillary question but it hasn't helped me.
  I have a column with merged and non-merged cells. I'd like to get their values. I don't know how to use it:</p>
  
  <pre><code>Set ma = myWorkbook.Range("C2").MergeArea
  sValue = ma.Cells(c.Row, 1).Value
  </code></pre>
  
  <p>Look at my code:</p>
  
  <pre><code>Private Function GetValueOfMergedCells(sName, iColumn)
      Set myWorkbook = Workbooks().Worksheets()
  
      Set c = myWorkbook.Cells.Find(What:=sName, After:=ActiveCell, LookAt _
                          :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext)
  
      If Not c Is Nothing Then
          If (iColumn &lt;&gt; 2) Then
              '...
          Else
              Set ma = NEWDevicesWS.Range("C2").MergeArea
              MsgBox ma.Cells(c.Row, 1).Value
              GetValueOfMergedCells = ma.Cells(c.Row, 1).Value
          End If
      Else
          '...
      End If
  End Function
  
  
  Sub main()
      Set firstWorkbook = Workbooks().Worksheets()
  
      ' Get array of strings
      Dim aNames() As String
          aNames = ImportSamplesNames() 
  
      For i = 1 To UBound(aNames())
          firstWorkbook.Cells(3 + i, 2) = GetValueOfMergedCells(aNames(i), 2)
      Next i
  End Sub
  </code></pre>
  
  <p>What do I do wrong?</p>