+ Reply to Thread
Results 1 to 3 of 3

Macro - Merge cell if same BL and sum and merge same BL

Hybrid View

  1. #1
    Registered User
    Join Date
    03-10-2015
    Location
    Philippines
    MS-Off Ver
    2010
    Posts
    85

    Macro - Merge cell if same BL and sum and merge same BL

    is this possible? same BL# will be merge at the same time Merge also the Balance PHP and SUM.

    see attached sample

    thanks
    Attached Files Attached Files
    Last edited by ash3angel; 04-08-2015 at 01:13 AM.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Macro - Merge cell if same BL and sum and merge same BL

    try
    Sub ertert()
    Dim i&, j&, Lr&, sm#
    Lr = Cells(Rows.Count, 1).End(xlUp).Row
    With Application
        .ScreenUpdating = False: .DisplayAlerts = False
        For i = 3 To Lr
            sm = Cells(i, 7): j = i
            Do While Cells(i, 1) = Cells(i + 1, 1)
                sm = sm + Cells(i + 1, 7)
                i = i + 1: If i > Lr Then Exit Do
            Loop
            If i > j Then
                Cells(j, 1).Resize(i - j + 1).Merge
                Cells(j, 7).Resize(i - j + 1).Merge
                Cells(j, 7).Value = sm
            End If
        Next i
        .ScreenUpdating = True: .DisplayAlerts = True
    End With
    End Sub

  3. #3
    Registered User
    Join Date
    03-10-2015
    Location
    Philippines
    MS-Off Ver
    2010
    Posts
    85

    Re: Macro - Merge cell if same BL and sum and merge same BL

    Great it works, i will try this codes using my new template and i hope it works fine too.
    i never imagine that it will be possible. you're the best.

    Thanks.

    sir please help again if i encounter error.

    Quote Originally Posted by nilem View Post
    try
    Sub ertert()
    Dim i&, j&, Lr&, sm#
    Lr = Cells(Rows.Count, 1).End(xlUp).Row
    With Application
        .ScreenUpdating = False: .DisplayAlerts = False
        For i = 3 To Lr
            sm = Cells(i, 7): j = i
            Do While Cells(i, 1) = Cells(i + 1, 1)
                sm = sm + Cells(i + 1, 7)
                i = i + 1: If i > Lr Then Exit Do
            Loop
            If i > j Then
                Cells(j, 1).Resize(i - j + 1).Merge
                Cells(j, 7).Resize(i - j + 1).Merge
                Cells(j, 7).Value = sm
            End If
        Next i
        .ScreenUpdating = True: .DisplayAlerts = True
    End With
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Email merge from excel merge file using pre-saved word template
    By d_max_c in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-17-2014, 12:33 PM
  2. Macro to merge cell if they are the same.
    By jonathan.haynes in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-03-2013, 05:03 AM
  3. Email Merge with variable merge records break by client level
    By sss047 in forum Word Formatting & General
    Replies: 0
    Last Post: 04-15-2011, 04:25 AM
  4. merge and reset a merge based on cell content
    By salkovsg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-30-2007, 07:08 PM
  5. Replies: 0
    Last Post: 04-21-2006, 03:40 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1