vba筛选数组问题

我有2组数据,第一组在A列,第二组在B列,
暂时假定AB有的数据都是1000个。
我想筛选出A列中有,但是B列中没有的数据,
(也就是说A列比B列多的数据)
多出来的数据,放在C列,
请问如何实现

Sub test()
Dim i, j, r As Long
Dim str As String
Dim findvalue As Range
r = Range("A65536").End(xlUp).Row
j = 1
For i = 1 To r
str = Cells(i, 1).Value
Set findvalue = ActiveSheet.Columns(2).Find(what:=str)
If findvalue Is Nothing Then
Cells(j, 3).Value = Cells(i, 1).Value
j = j + 1
End If
Next i
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-01-27
可用两种方法实现,一是循环法,二是字典法。
第2个回答  2011-01-27
Sub Macro2()
Dim c As Range
Dim i As Long, j As Long
Dim a As String
j = 0
With Columns("B")
For i = 1 To 65536
If Cells(i, 1) = "" Then Exit For
a = Cells(i, 1)
Set c = .Find(a, LookIn:=xlValues, LookAt:=xlWhole)
If c Is Nothing Then
j = j + 1
Cells(j, 3) = a
End If
Next i
End With
End Sub

相关了解……

你可能感兴趣的内容

大家正在搜

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网