Option Explicit
Sub CompareInterpolation()
Dim wsOriginal As Worksheet, wsInterpol As Worksheet
Dim rwOriginal As Long, rwOriginalMax As Long
Dim rwInterpol As Long, rwInterpolMax As Long
Dim arOriginal() As Variant, arInterpolData() As Variant, arInterpolResult() As Variant
Const Limit As Single = 0.02
Set wsOriginal = Worksheets("Original Data")
Set wsInterpol = Worksheets("Intepolation")
rwOriginalMax = wsOriginal.Range("A1").CurrentRegion.Rows.Count
rwInterpolMax = wsInterpol.Range("A1").CurrentRegion.Rows.Count
arOriginal = wsOriginal.Range("A1:E" & rwOriginalMax)
arInterpolData = wsInterpol.Range("A1:B" & rwInterpolMax)
wsInterpol.Range("K2:O" & rwInterpolMax).ClearContents
arInterpolResult = wsInterpol.Range("K1:O" & rwInterpolMax)
For rwInterpol = 2 To rwInterpolMax
For rwOriginal = 2 To rwOriginalMax
If Abs(Round(arInterpolData(rwInterpol, 1), 3) - arOriginal(rwOriginal, 1)) <= Limit _
And Abs(Round(arInterpolData(rwInterpol, 2), 3) - arOriginal(rwOriginal, 2)) <= Limit Then
arInterpolResult(rwInterpol, 1) = arOriginal(rwOriginal, 1)
arInterpolResult(rwInterpol, 2) = arOriginal(rwOriginal, 2)
arInterpolResult(rwInterpol, 3) = arOriginal(rwOriginal, 3)
arInterpolResult(rwInterpol, 5) = arOriginal(rwOriginal, 5)
Exit For
End If
Next rwOriginal
Next rwInterpol
wsInterpol.Range("K1:O" & rwInterpolMax) = arInterpolResult
End Sub
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.