Reputation: 191
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:
Set ma = myWorkbook.Range("C2").MergeArea
sValue = ma.Cells(c.Row, 1).Value
Look at my 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 <> 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
What do I do wrong?
Upvotes: 0
Views: 1593
Reputation: 29421
can't track down your code
so hope that:
ma.Resize(1, 1).Value
would do
Upvotes: 1