The following function accepts two dynamic ranges as arguments, finds the percentage difference between each element in the "original" range and it's corresponding element in the "correct" range, and returns the maximum difference.

Function MaxRate(original As Range, correct As Range) As Double

Dim N As Long, i As Long

Dim h() As Double

N = Application.WorksheetFunction.Count(original)

ReDim h(1 To N)

For i = 1 To N

h(i) = (correct(i) - original(i)) / original(i)

Next i

MaxRate = Application.WorksheetFunction.Max(h)

End Function

When either range contains an NA value I'm getting a type-mismatch error. I'd like the function to include an error-checking statement such as ISNUMBER that allows it to simply skip elements that contain "NA", but the function either doesn't work at all when I try to include one or doesn't do what I want it to. I'm a noob at this and any help at all would be greatly appreciated.