Get second smallest & second largest from a range

hsandeep

Well-known Member
Joined
Dec 6, 2008
Messages
1,226
Office Version
  1. 2010
Platform
  1. Windows
  2. Mobile
My range is K2:V2 which generates values including 0 and also “” (blank)
I need formulas:
AA2=Second smallest non-zero non blank number from K2:V2 else 0
AB2= Second largest non-zero non blank number from K2:V2 else 0

How to accomplish?
Thanks in advance.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Do you want a value of zero to be considered in the function as a number?
 
Upvote 0
Maybe something like this:

Excel Formula:
=LARGE(K2:V2,2)
Excel Formula:
=SMALL(K2:V2,2)
 
Upvote 0
Try:
These are array formulas and must be entered with CTRL-SHIFT-ENTER

Book1
KLMNOPQRSTUVWAAAB
1123456789101112
201067141595420515
Sheet2
Cell Formulas
RangeFormula
AA2AA2=IFERROR(SMALL(IF(K2:V2<>0,IF(K2:V2<>"",K2:V2)),2),0)
AB2AB2=IFERROR(LARGE(IF(K2:V2<>0,IF(K2:V2<>"",K2:V2)),2),0)
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Another option
Fluff.xlsm
KLMNOPQRSTUVWXY
1123456789101112
20106714159 5420 515
Master
Cell Formulas
RangeFormula
R2,V2R2=""
X2X2=AGGREGATE(15,6,K2:V2/(K2:V2<>0),2)
Y2Y2=LARGE(K2:V2,2)
 
Upvote 0
@Fluff
I keep forgetting to divide by the edit on the SMALL function in AGGREGATE, Thanks for having me see this reminder.

I do have a question, how do you account if there are no positive numbers in the LARGE function, the zero is counted here:
Book1
ABCD
8-2-10-1
Sheet1
Cell Formulas
RangeFormula
D8D8=LARGE(A8:C8,2)
 
Upvote 0
how do you account if there are no positive numbers in the LARGE function, the zero is counted here:
Good point, if that is a possibilty, then I'd use aggregate again.
 
Upvote 0
AhoyNC
The number 2 used in the formulas, is it for the "second". So, if I replace 2 with 1 in the formulas, will it be giving smallest & largest respectively?
 
Upvote 0
Yes the number 2 is for second. If you replace with 1 it will give the smallest - largest number.
Fluff's formula does not require CTRL-SHIFT-ENTER, but you need to add the IFERROR function to his formula if all the cells are blank and you want to return 0.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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