Solved

Excel Macro to combine cells if duplicate

Posted on 2016-09-14
2
30 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:Wass_QA
2 Comments
 
LVL 48

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:Wass_QA
ID: 41797904
Thank you very much,
worked like a treat.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

708 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

19 Experts available now in Live!

Get 1:1 Help Now