例如:
专栏 A: (215) 640-1037列 B:215.640.1037
我只想比较两列中的数字,看看它们是否相同,但我不确定如何做到这一点。
UDF 时间!将此函数放入工作簿中,然后在 C 列中输入=compare(a1,b1)
Public Function COMPARE(Value1 As String, Value2 As String) As Boolean
Dim subVal1 As String
Dim subVal2 As String
subVal1 = ""
subVal2 = ""
For x = 1 To Len(Value1)
If IsNumeric(Left(Value1, 1)) Then
subVal1 = subVal1 & Left(Value1, 1)
End If
Value1 = Right(Value1, Len(Value1) - 1)
Next x
For x = 1 To Len(Value2)
If IsNumeric(Left(Value2, 1)) Then
subVal2 = subVal2 & Left(Value2, 1)
End If
Value2 = Right(Value2, Len(Value2) - 1)
Next x
If subVal1 = subVal2 Then
COMPARE = True
Else
COMPARE = False
End If
End Function
也许:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"(",""),")","")," ",""),"-",""),".","")=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B1,"(",""),")","")," ",""),"-",""),".","")