excel如何找出两列中同时不重复的值?
发布网友
发布时间:2022-04-24 01:25
我来回答
共2个回答
热心网友
时间:2023-10-18 08:59
按alt+f11,插入--模块,复制以下代码粘贴,alt+f4,alt+f8,选不重复值,执行。
Sub 不重复值()
Dim h, s(65600), g, g1, l, h1
h1 = 2
For h = 2 To 65535
If Cells(h, 1) <> "" Then
s(g) = h
g = g + 1
End If
Next h
Do While s(g1) <> ""
Cells(h1, 4) = Cells(s(g1), 1)
Cells(h1, 5) = Cells(s(g1), 2)
Cells(h1, 6) = Cells(s(g1), 3)
g2 = g1 + 1
l = 7
Do While s(g2) <> ""
If Cells(s(g2), 2) = Cells(s(g1), 2) And Cells(s(g2), 3) = Cells(s(g1), 3) Then
Cells(h1, l) = Cells(s(g2), 1)
l = l + 1
For c = g2 To g - 1
s(c) = s(c + 1)
Next c
Else
g2 = g2 + 1
End If
Loop
g1 = g1 + 1
h1 = h1 + 1
Loop
End Sub
热心网友
时间:2023-10-18 08:59
按照你的格式显示的话要编vba程序追问可以不按这个格式,只要找到结果就ok了
追答那就用countif函数