如何比较两个excel列中的数字?

时间:2015-01-21 14:25:15

标签: excel compare

例如:

A栏:(215)640-1037 B栏:215.640.1037

我只想比较两列中的数字,看看它们是否相同,但我不知道如何去做。

2 个答案:

答案 0 :(得分:0)

也许:

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"(",""),")","")," ",""),"-",""),".","")=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B1,"(",""),")","")," ",""),"-",""),".","")

答案 1 :(得分:0)

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