I have data around 400+ records in column "A" & various detail in column "B". A total of 3000+ rows in the sheet which look like Example:
Column A Column B
CHI150 UPS1
CHI150 TOWER1
CHI150 TOWER2
CHI160 EB1
CHI160 UPS1
CHI160 TOWER1
CHI163 EB1
CHI163 TOWER2
CHI163 UPS2
CHI195 TOWER1
CHI195 EB1
I want do concatenate the data like below mentioned.
Column A Column B
CHI150 UPS1, TOWER1, TOWER2
CHI160 EB1, UPS1, TOWER1
CHI163 EB1, TOWER2, UPS2
CHI195 TOWER1, EB1
Kindly give the solution & Thanks in advance
Assuming you have the data in Column A & B from A2 and B2 cells respectively..
Sub test() 'change the sheet name as yours Sheets("Sheet1").Activate 'Change the range as yours and you need update the column as well in cells(rows.count,1) Set Rng = Range("A2", Cells(Rows.Count, 1).End(xlUp)) Set rng1 = Range("D2", Cells(Rows.Count, 4).End(xlUp)) Range("A2", Cells(Rows.Count, 1).End(xlUp)).Copy 'copy pasteing the column A and removing duplicates Range("D2").PasteSpecial xlPasteValues ActiveCell.RemoveDuplicates Columns:=1, Header:=xlNo ' now concordinating the values For Each cell In rng1 For Each cell1 In Rng If cell.Value = cell1.Value Then If cell.Offset(0, 1).Value = "" Then cell.Offset(0, 1).Value = cell1.Offset(0, 1).Value Else cell.Offset(0, 1).Value = cell.Offset(0, 1).Value & ", " & cell1.Offset(0, 1).Value End If End If Next cell1 Next cell End Sub
The above macro will generated the result in column D form D2. Hope this is what your expecting..
Thanks for making the changes in your question to explain it better.
I took a sample sheet similar to your problem, and was able to get the desired result in a new column C. Try below steps
Put below formula to all rows of column C starting from row 2 (ie C2). This will check if value on column A at current row is similar to the previous row, and shall append the values of the column B to the calculated value in Column C for previous row.
=IF(A2=A1, (C1 & ", " & B2), B2)
For all the rows of column D, put below formula starting with row 1
=IF(A1=A2,"","Changed")
This should fill some of the rows for column D with "Changed", you could then filter for the column D for only the records that contain "Changed" as value.
This should get you desired result.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.