-1
A
回答
0
沒有更多的上下文/信息,我只能給你一個高層次的迴應,但希望它能讓你開始。
要檢查是否在一個範圍內的項目在其他範圍內被發現,下面的代碼構建從一個範圍的字符串,然後使用「INSTR」對每個項目從反對另一個範圍進行比較。爲了做更復雜的比較,我會從範圍中構建數組。
Sub CompareLists()
Dim rng1 As Range, rng2 As Range
Dim cell As Range
Dim tmp As String
Set rng1 = Worksheets("Sheet1").Range("A1:A6")
Set rng2 = Worksheets("Sheet2").Range("A1:A6")
'Build pipe-delimited string from cells in range
For Each cell In rng1
tmp = tmp & cell & "|"
Next cell
'Remove last pipe
tmp = Left(tmp, Len(tmp) - 1)
'Loop list 2 and compare against list 1.
'Specifically, see if each item in list 2 is found in list 1
For Each cell In rng2
If InStr(1, tmp, cell) > 0 Then
'Print items from list 2 that are found in list 1
Debug.Print "Found: " & cell.Value
Else
'Print items from list 2 that are NOT found in list 1
Debug.Print "NOT Found: " & cell.Value
End If
Next cell
Set rng1 = Nothing
Set rng2 = Nothing
Set cell = Nothing
末次
相關問題
- 1. 發現大數值的重複次數
- 2. 張量流不能實現重複性
- 3. 發現重複行
- 4. 發現重複3
- 5. VBA到Vlookup內循環比較兩張之間的數據並粘貼重複值在第三張表
- 6. 發現重複的JavaScript
- 7. 發現不重複的字
- 8. MySQL的發現重複
- 9. ELKI的重複數據的LOF實現
- 10. 從第三張表中檢索數據
- 11. 計數重複三元組
- 12. 重複發現查詢的JSON數據 - postgress
- 13. CakePHP:覆蓋現有的重複數據
- 14. 在PHP數組中發現重複值
- 15. 火炬 - 重複張量像numpy重複
- 16. 重複條目X發現
- 17. 發現重複號碼
- 18. Angularjs發現NG重複
- 19. 軌,發現Postgres數據庫重複條目
- 20. vba:將三列過濾的數據複製到另一張紙的一行
- 21. 在每張印張上重複內容
- 22. 現在重複數據驅動測試
- 23. 三維重建的投影矩陣從三焦張量
- 24. 計數的重複出現
- 25. 刪除Excel中三列之一中的重複數據
- 26. 給我發送重複數據
- 27. vbs腳本發送數據並重復
- 28. 發送數據形式NG重複
- 29. 重複數據
- 30. 重複數據
你的問題很模糊。請給我們更多的細節。你想比較哪種數據?如果可能,請給我們一個簡短但實際的例子。一個很好的比較/匹配函數是vba中的'range.find'方法。看看[這裏](https://msdn.microsoft.com/en-us/library/office/ff839746.aspx)。 –