excel匹配一个有很多值的人

时间:2016-05-20 06:55:37

标签: excel

我有两个系统之间要协调的数据。一个系统可能会报告值100但在另一个系统50上报告两次。我需要将它们视为可能的匹配。 但并非每条记录都有可能匹配

Column A   Column B
SAP system Local system
100.00          50.00
435.00          50.00
146.25          435.00
53.75           253.50

我应该得出结论100具有匹配数据(50& 50)& 435有匹配的数据。我可以使用公式匹配精确的数据,但是有没有办法匹配像100.00这样的值的组合?

1 个答案:

答案 0 :(得分:0)

此函数将找到第一个匹配对并返回B列中匹配数字的位置,称为: -

=FindPair(A2,B2:B5)



Option Explicit

Function FindPair(TotVal As Range, SearchVals As Range) As String

Dim Tot As Integer, i As Long, j As Long, length As Long, SearchVal As Double, found As Boolean
Dim store() As Double
Dim sum As Double

length = SearchVals.Rows.Count

ReDim store(length)
SearchVal = TotVal.Cells(1, 1).Value

For i = 1 To length
    store(i) = SearchVals(i)
Next i

found = False
FindPair = ""
For i = 1 To length - 1
    sum = store(i)
    For j = i + 1 To length
        If (sum + store(j)) = SearchVal Then
            found = True
            GoTo finish
        End If
    Next j
Next i

finish:
If found Then
   FindPair = CStr(i) & "," & CStr(j)
End If

End Function