How to select merged cell in VBA Excel – debugvba.com

Select merged cell VBA

Objective

To select the merged cell and highlight them using VBA Excel.

Approach

Here we had 3 cells C8, D8, E8 which were merged before executing the code. To highlight the merged cell we need to select the left most cell in the merged cell, which is C8 in this case. If we change the colour of C8 , colour of all three merged cell are also changed.

Code

 

Sub SelectMergeCell()

'Highlight the merged cell

Range("C8").Select

Range("C8").Interior.Color = RGB(255, 255, 0)

End Sub

 

In the code above we have only changed the colour of cell C8, but since the cell C8,D8,E8 were already merged, so the colour of entire merged cell changed.

 

Select merged cell VBA

 

Post you may like

How to delete blank or empty cells using VBA Excel