我正在尝试在2个数组中获得无法匹配的字符串。我试过这个How to search for string in an array,但它们返回真或假。
dim arr1 as variant
dim arr2 as variant
arr1 = "abc,def,ghi,jkl"
arr2 = "abc,def,ghi,jkl,pre,ec,vw"
但我正试图让字符串像 结果= “预,EC,VW” 如何在vba中指定
答案 0 :(得分:0)
试试这个
result=replace(arr2,arr1,"")
列出arr2但不在arr1
中的子串Sub aargh()
arr1 = "abc,def,ghi,jkl"
arr2 = "abc,def,ghi,zer,jkl,pre,ec,vw"
a = Split(arr1, ",")
For i = LBound(a) To UBound(a)
arr2 = Replace(arr2, a(i), "")
Next i
ol = 0
While Len(arr2) <> ol
ol = Len(arr2)
arr2 = Replace(arr2, ",,", ",")
Wend
If Left(arr2, 1) = "," Then arr2 = Mid(arr2, 2)
MsgBox arr2
End Sub