Consulting

Results 1 to 3 of 3

Thread: VBA Merging duplicate -cells issue

  1. #1
    Banned VBAX Contributor
    Joined
    Aug 2017
    Posts
    144
    Location

    VBA Merging duplicate -cells issue

    -Hi Team
    
    Please assist in merging Duplicate cells
    -Column B and A . Column b -contains names in -ascending order.
    and -Column A Contains count of duplicate value from columnnB
    
    
    Attached are my workbook.& expected result In column EF
    
    
    
    
    
    
    
    
    Thanks
    mg
    Attached Files Attached Files

  2. #2
    VBAX Expert
    Joined
    Sep 2016
    Posts
    788
    Location
    Sub MergeCells2()
        Dim ws As Worksheet
        Dim lRow As Long
        Dim i As Long
        
        Set ws = Sheet1
        lRow = ws.Cells(Rows.Count, "A").End(xlUp).Row
        
        Application.DisplayAlerts = False
    
        For i = lRow To 3 Step -1
            If ws.Cells(i, 2) = ws.Cells(i - 1, 2) Then
                ws.Cells(i - 1, 1).Resize(2).Merge
                ws.Cells(i - 1, 2).Resize(2).Merge
            End If
        Next i
    
        Application.DisplayAlerts = True
        
    End Sub

  3. #3
    Banned VBAX Contributor
    Joined
    Aug 2017
    Posts
    144
    Location
    Hi Mana,

    Superb !!! It worked as expected, you covered both column merging in a single loop thats awesome

    Thanks a lot

    regards,
    mg

Posting Permissions

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