I have some simple code to find a max of a range and then return the row where the max value is located. For some reason, there are instances where the Match
returns an Error 2042
, but most of the time it runs successfully. How is it that it can't find a match in a range when the value I'm searching for is the max value of that same range?
The values in the range are percentages with many significant digits (eg 0.992149823976789%).
Sub test()
dim rng as range
Set rng = Range("A1:A100")
rng_max = application.max(rng)
max_row = application.match(cdbl(rng_max), rng.value, 0)
End Sub