Return index for the smallest positive number in column

smide

Board Regular
Joined
Dec 20, 2015
Messages
162
Office Version
  1. 2016
Platform
  1. Windows
Hello.


In both columns A and B (A1:A600, B1:B600) I have numbers/indexes in ascending order.
Column A range is from zero up to a 599. Column B could contain negative numbers.


I need to return index from column A for the smallest positive number from column B. Result should be placed in cell C1.


Zero should be treated as negative number in formula.
Column B could repeat the same numbers and it that case return index for the first number.


example.


ABC
10-124
21-5
32-1
430
541
651
762
873
983

<tbody>
</tbody>

explanation: One (cells B5 and B6) is the smallest positive number in column B. Result in C1 should be 4 because it's a corresponding index from column A (cell A5).
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi, here is one option.


Excel 2013/2016
ABC
10-124
21-5
32-1
430
541
651
762
873
983
Sheet1
Cell Formulas
RangeFormula
C1=INDEX(A1:A600,MATCH(AGGREGATE(15,6,B1:B600/(B1:B600>0),1),B1:B600,0))
 
Upvote 0
Sorry, I forgot to mention, I'm using excel 2007, so aggregate function is not an option for me...:(
Do you have any idea what can I use instead of 'aggregate' function?
 
Upvote 0
Do you have any idea what can I use instead of 'aggregate' function?

Hi, take note of the array entry instructions.


Excel 2013/2016
ABC
10-124
21-5
32-1
430
541
651
762
873
983
Sheet1
Cell Formulas
RangeFormula
C1{=INDEX(A1:A600,MATCH(MIN(IF(B1:B600>0,B1:B600)),B1:B600,0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
It's ok now. Works great. Thank you.;)
 
Upvote 0
If you would prefer a normal-entry formula then you could see if either of these suit.

The C1 formula takes your statement "Column A range is from zero up to a 599" literally.
If the values in column A may not start at zero or continually increment by 1 then try the C2 formula.

Both formula rely on your statement about ascending order: "(A1:A600, B1:B600) .. have numbers/indexes in ascending order."

Excel Workbook
ABC
10-124
21-54
32-1
430
541
651
762
873
983
Index
 
Upvote 0

Forum statistics

Threads
1,213,495
Messages
6,113,992
Members
448,538
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top