[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Excel Macro to combine cells if duplicate

Posted on 2016-09-14
2
Medium Priority
?
65 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 54

Accepted Solution

by:
Rgonzo1971 earned 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

834 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