答案1
使用 VBA/宏:
Public Sub myDuplicates()
Dim wks As Worksheet
Set wks = ActiveSheet
emailcolumn = 4
totalcolumns = 12
merges = 0
theSymbol = " / "
Application.ScreenUpdating = False
lastRow = wks.Cells(Rows.Count, "A").End(xlUp).Row
For i = lastRow To 1 Step -1
email1 = wks.Cells(i, emailcolumn)
For j = i - 1 To 2 Step -1
email2 = wks.Cells(j, emailcolumn)
If LCase(email1) = LCase(email2) Then
For k = 1 To totalcolumns
If LCase(Cells(i, k)) <> LCase(Cells(j, k)) Then
Cells(j, k) = Cells(j, k) & theSymbol & Cells(i, k)
End If
Next k
wks.Rows(i).Delete
j = 1
merges = merges + 1
End If
Next j
Next i
Application.ScreenUpdating = True
theMessage = MsgBox("Finished with " & merges & " merges", vbInformation)
End Sub
打开 VBA/Macros,在下方插入一个新模块本工作簿并将此代码粘贴到右侧。
当两封电子邮件相同时,它会合并所有不同的仅限字段。并使用/
在单元格内分隔它们。
它假设您的电子邮件字段是第四列。可以使用变量进行更改emailcolumn
,并假设您的最大列数为 12,也可以在变量上轻松更改totalcolumns
。