Excel VBA – 总结不同的项目

PPL

我有像这样的数据:

ID | Country 1 | DE 1 | GB 2 | DE 2 | DE 3 | GB 

使用我的macros后,我有以下数据:

 1 | DE;GB 2 | DE 3 | GB 

我喜欢的是:

 1 | DE(1);GB(1) 2 | DE(2) 3 | GB(1) 

我不确定我的代码是如何完成这些工作的,可以帮我处理我的请求吗?

附上我的代码:

 Public Sub Calc() Z = 2 z2 = 1 Do Until Cells(Z, 5).Value = "" If Cells(Z, 5).Value <> Kunde_Alt Then z2 = z2 + 1 Cells(z2, 9).Value = Cells(Z, 5).Value End If s = 10 Land = Cells(Z, 6).Value Gef = False Do Until Cells(z2, s).Value = "" If Cells(z2, s).Value = Land Then Gef = True Exit Do End If s = s + 1 Loop If Gef = False Then Cells(z2, s).Value = Land End If Kunde_Alt = Cells(Z, 5).Value Z = Z + 1 Loop End Sub