Find RowValue of smallest non-zero number with a non-zero number in the column next to it

Hello everybody

I have the following problem:
I want to find the rowvalue of the smallest number in a column, however if there is a zero in the column next to it, I don’t want that number. I feel like there might be a simple solution to this problem but I can’t seem to find it ( all of my ideas feel overly convoluted).

In this example:
      A      B
1.   0      5
2.   6      20
3.   2      0
4.   7      5
5.   4      60

In this example, I want to return 4
A1 is the smallest value in column A, but it is zero, so it doesn’t count
A3 is the second smallest value in column A, but it doesn’t count because B3 is zero
A5 is the third smallest number, so I want this rownumber

I have limited experience in VBA but some experience in programming in general.

Thank you

By: Emiel Wittevrongel

Leave a Reply

Your email address will not be published. Required fields are marked *