如何查看数组是否包含在列中?
问题描述:
我正在寻找一个vba代码来查明一列中的单元格是否包含字符串数组(不完全匹配)。我有一张存储在工作表中的虚假电子邮件列表,另一张表中有我想查看的电子邮件列表。如果在第二列中找到第一个列表中的电子邮件,我需要将该行用黄色着色。 这里是我有:如何查看数组是否包含在列中?
Dim list As String, c As Range, count As Long, total As Long
count = 1
total = Range("I" & Rows.count).End(xlUp).Row
For ix = 1 To total
list = Worksheets("Helper").Range("A" & counter).Value
k = "a" & count
For Each c In Worksheets("JP").Range(k)
c.EntireRow.Interior.Color = 255
Next c
End If
End If
count = count + 1
Next ix
答
要检查字符串包含在另一个,你会做这样使用
If InStr(1, str, substr, vbTextCompare) > 0) Then
' put logic for when substr is within str
End If
这将返回SUBSTR的正数范围内STR随处可见。
对于您的特定应用程序,我将调试您的循环,它看起来像你在正确的轨道上