在Excel中组合具有相同值的行

我是新来的与Excel的工作,并想知道如果以下是可能的。

我有以下格式的文件

R1 R2 200 A 201 A 202 A 202 A 203 A 205 B 203 B 202 B 202 C 203 C 

我想要转换的数据如下:

 R1 R2 200,201,202,203 A 205,203,202 B 202,203 C 

请让我知道,如果上述可以在Excel中完成。

谢谢。

用你的数据在AB列中,这个短的macros:

 Sub ReOrg() Dim nA As Long, nD As Long, i As Long, rc As Long Dim s As String, j As Long Range("B:B").Copy Range("D1") Range("A1").Copy Range("C1") Range("D:D").RemoveDuplicates Columns:=1, Header:=xlYes rc = Rows.Count nA = Cells(rc, 1).End(xlUp).Row nD = Cells(rc, 4).End(xlUp).Row For i = 2 To nD v = Cells(i, 4) v2 = "" For j = 2 To nA If v = Cells(j, 2) Then v2 = v2 & "," & Cells(j, 1) End If Next j Cells(i, 3) = Mid(v2, 2) Next i End Sub 

会产生:

在这里输入图像说明