Consulting

Results 1 to 4 of 4

Thread: How to find the first and last row of merge Cells???

  1. #1

    Question How to find the first and last row of merge Cells???

    Hi all,
    Could you please help me!!! How to find the starting row and ending row of merge cells using the vbscript.

    Suppose if i have merged B1 to B9 my output should be
    Starting row of merge cells is "1"
    Ending row of merge cells is "9"








    Thanks InAdvance!!!
    Sankar
    Thanks
    Sankar

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Dim cell As Range
    For Each cell In ActiveSheet.UsedRange
    If cell.MergeCells Then
    If cell.Address = cell.MergeArea.Cells(1, 1).Address Then
    MsgBox "Starts in: " & cell.Row & vbNewLine & _
                       "Ends in: " & cell.MergeArea(cell.MergeArea.Count).Row
                End If
            End If
    Next cell
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thanks alot Xld...
    Thanks
    Sankar

  4. #4
    VBAX Regular
    Joined
    Feb 2010
    Posts
    29
    Location
    Quote Originally Posted by xld
    Dim cell As Range
    For Each cell In ActiveSheet.UsedRange
    If cell.MergeCells Then
    If cell.Address = cell.MergeArea.Cells(1, 1).Address Then
    MsgBox "Starts in: " & cell.Row & vbNewLine & _
    "Ends in: " & cell.MergeArea(cell.MergeArea.Count).Row
    End If
    End If
    Next cell
    Thank xld very much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •