Return index for the smallest positive number in column

smide

Board Regular
Joined
Dec 20, 2015
Messages
164
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.


[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"]-12[/TD]
[TD="align: center"]4[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]-5[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]-1[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]6[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]8[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]9[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]3[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
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,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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