部分单元格匹配和忽略标点VBA
这是我们的延伸问题 如果名字中有标点符号,我想知道如何进一步改进John Coleman提供的以下代码 Name1的一个例子是“IT主管Sally,Lim” Name2的一个例子是“Sally,Lim” 使用函数“整理”字符串:部分单元格匹配和忽略标点VBA,vba,excel,punctuation,Vba,Excel,Punctuation,这是我们的延伸问题 如果名字中有标点符号,我想知道如何进一步改进John Coleman提供的以下代码 Name1的一个例子是“IT主管Sally,Lim” Name2的一个例子是“Sally,Lim” 使用函数“整理”字符串: Function ReplacePunct(strInput As String) As String chars = Array(".", ",", ";", ":") '// Change as required For Each ch In chars
Function ReplacePunct(strInput As String) As String
chars = Array(".", ",", ";", ":") '// Change as required
For Each ch In chars
While InStr(strInput)
strInput = Replace(strInput, CStr(ch), vbNullString)
Wend
End If
End Function
然后像这样使用它:
If UCase(Trim(ReplacePunct(Name1))) Like "*" & UCase(Trim(ReplacePunct(Name2))) & "*" then
If UCase(Trim(ReplacePunct(Name1))) Like "*" & UCase(Trim(ReplacePunct(Name2))) & "*" then