Solved

Excel Macro to combine cells if duplicate

Posted on 2016-09-14
2
35 Views
Last Modified: 2016-09-14
Hello,
can you please help with an Excel  Sub.,
if rows are the same (Column A,B,C,D,E), THEN combine Cells in Column F (remove NO.) , separated by comma.
and Delete rows.

Attached is a sample,
Your help is very much appreciated.

thanks,
sample.xlsx
0
Comment
Question by:W.E.B
2 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41797890
Hi,

pls try
Sub macro1()

For Idx = Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
    Set c = Range("A" & Idx)
    If c = c.Offset(-1) And c.Offset(, 1) = c.Offset(-1, 1) And _
            c.Offset(, 2) = c.Offset(-1, 2) And c.Offset(, 3) = c.Offset(-1, 3) And _
            c.Offset(, 4) = c.Offset(-1, 4) Then
        c.Offset(-1, 5) = c.Offset(-1, 5) & ", " & Right(c.Offset(, 5), Len(c.Offset(, 5)) - 4)
        c.EntireRow.Delete
    End If
    
Next
End Sub

Open in new window

Regards
0
 

Author Closing Comment

by:W.E.B
ID: 41797904
Thank you very much,
worked like a treat.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now