Get start range and end range of a vertically merged cell with Excel using VBA

前端 未结 6 884
有刺的猬
有刺的猬 2020-12-10 13:02

I need to find out the first cell and the last cell of a vertically merged cell..

Let\'s say I merge Cells B2 down to B50.
How can I get in VBA the start cell(=B

6条回答
  •  死守一世寂寞
    2020-12-10 13:38

    Suppose you merged B2 down to B50.

    Then, start cell address will be:

    MsgBox Range("B2").MergeArea.Cells(1, 1).Address
    

    End cell address will be:

    With Range("B2").MergeArea
        MsgBox .Cells(.Rows.Count, .Columns.Count).Address
    End With
    

    You can put address of any cell of merged area in place of B2 in above code.

提交回复
热议问题