在Excel列中查找缺less的数据
我正在使用Excel 2003,并试图比较两列来查找不在另一列中的数据。
例如:
在VBA中,你可以尝试下面的丑陋但工作代码:
Sub missing() Dim ya As Long, yb As Long, yc As Long, alast As Long, blast As Long Dim flag As Boolean yc = 2 yb = 2 flag = 0 alast = Range("A65536").End(xlUp).Row blast = Range("B65536").End(xlUp).Row For ya = 2 To alast flag = 0 Do While yb <= blast If Range("A" & ya) = Range("B" & yb) Then flag = 1 yb = yb + 1 Loop If flag = 0 Then Range("C" & yc) = Range("A" & ya) yc = yc + 1 End If yb = 2 Next ya End Sub