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

calendar_today Asked Jun 1, 2010
thumb_up 11 upvotes
history Updated April 16, 2026

Question posted 2010 · +7 upvotes

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(=B2) and the end cell(=B50)?

Accepted answer +11 upvotes

Sub MergedAreaStartAndEnd()

    Dim rng As Range
    Dim rngStart As Range
    Dim rngEnd As Range

    Set rng = Range("B2")

    If rng.MergeCells Then

        Set rng = rng.MergeArea
        Set rngStart = rng.Cells(1, 1)
        Set rngEnd = rng.Cells(rng.Rows.Count, rng.Columns.Count)

        MsgBox "First Cell " & rngStart.Address & vbNewLine & "Last Cell " & rngEnd.Address

    Else

        MsgBox "Not merged area"

    End If

End Sub

Excel VBA objects referenced (4)

  • Columns.Count — Count function (Microsoft Access SQL)
  • Columns.Count — Count the number of records in a DAO Recordset
  • Range — Refer to Cells by Using a Range Object
  • Range — Delete Duplicate Entries in a Range

Top excel-vba Q&A (6)

+11 upvotes ranks this answer #55 out of 136 excel-vba solutions on this site .