Solved

Excel Macro to combine cells if duplicate

Posted on 2016-09-14
2
38 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

815 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

12 Experts available now in Live!

Get 1:1 Help Now