VBA Merged Cell

Asked

Viewed 735 times

0

Good afternoon,

Does anyone have any idea how to return the value of a merged cell in VBA programming ?

inserir a descrição da imagem aqui

For example: I would like range N6 to return MAI/19

2 answers

1

Because the cell is merged with the VBA it uses as parameter the first cell that was merged, so the MAI/2019 value is in cell E6.

0


To obtain the value directly, the value of the leftmost and uppermost cell is usually used. But there is a better way to get, as can be seen in the following code:

Sub valor_mesclado()
    MsgBox Range("H6").MergeArea.Cells(1, 1).Value
    MsgBox Range("E6").MergeArea.Cells(1, 1).Value
End Sub

Browser other questions tagged

You are not signed in. Login or sign up in order to post.