How can I use VBA in Excel to determine the max/min of a range that contains error cells such as #N/A
or empty cells? I know this is a fairly easy task to conquer with Excel array formulas using something like=MIN(IF(A1:A10="#N/A"))
but I would very much like to accomplish this using VBA.
I'm dealing with several thousand lines of data so the speediest solution would be preferred.
Thank you so much!
You can use Evaluate
or the shortcut []
to return the VBA equivalent of a formula
So the Excel array formula=MIN(IF(NOT(ISNA(A1:A10)),A1:A10))
can be used in code like
Sub Test()
MsgBox [MIN(IF(NOT(ISNA(A1:A10)),A1:A10))]
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With