宏匹配两列,然后显示一个消息框,其中not
匹配的条目,我一直在尝试,但无法弄清楚如何回发到工作表(" YYY")
由于
Sub so_whats_missing_2()
Dim u() As Boolean, v()
Dim a, b, c, q
With Sheets("XXX")
a = .Cells(2, 1).Resize(.Cells(Rows.Count, 1).End(3).Row)
aLR = (.Range("A" & .Rows.Count).End(xlUp).Row)
End With
With Sheets("YYY")
b = .Cells(2, 1).Resize(.Cells(Rows.Count, 1).End(3).Row)
End With
ReDim u(Application.Max(a, b))
ReDim v(UBound(u))
For Each c In b
u(c) = True
Next
For Each c In a
If Not u(c) Then v(c) = True
Next
q = "Missing from Sheet2 ..." & vbLf
For c = 1 To UBound(v)
If v(c) Then q = q & c & vbLf
Next
MsgBox q
End Sub
答案 0 :(得分:1)
而不是MsgBox q
执行Sheets("YYY").Cells(1,2).Value = q
。