Combine rows using condition
Closed
pankaj.pandey
Posts
1
Registration date
Monday December 2, 2013
Status
Member
Last seen
December 2, 2013
-
Dec 2, 2013 at 11:59 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Dec 5, 2013 at 10:46 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Dec 5, 2013 at 10:46 AM
Related:
- Combine rows using condition
- Combine notifications viber - Guide
- Linux combine split files - Guide
- Air condition lidl - Home - Apps & Sites
- If condition in excel - Guide
- How to delete rows and columns in word - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Dec 5, 2013 at 10:46 AM
Dec 5, 2013 at 10:46 AM
Hi Pankaj,
I put your sample data in column D and E. Make sure that duplicate entry's are adjacent to each other as they are now (use sort if they are not).
The following code will put result in columns A, B and C:
Best regards,
Trowa
I put your sample data in column D and E. Make sure that duplicate entry's are adjacent to each other as they are now (use sort if they are not).
The following code will put result in columns A, B and C:
Sub RunMe() Dim lRow As Integer lRow = Range("D1").End(xlDown).Row For Each cell In Range("D1:D" & lRow) If cell.Value = Range("A" & Rows.Count).End(xlUp).Value Then Range("B" & Rows.Count).End(xlUp) = Range("B" & Rows.Count).End(xlUp) & ", " & cell.Offset(0, 1) Range("C" & Rows.Count).End(xlUp) = Range("C" & Rows.Count).End(xlUp) + 1 Else Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = cell.Value Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = cell.Offset(0, 1).Value Range("C" & Rows.Count).End(xlUp).Offset(1, 0) = 1 End If Next cell End Sub
Best regards,
Trowa