Formula Help: Find the largest number that ends with a certain digit

Chris The Rock

Active Member
Joined
Feb 24, 2002
Messages
287
I know the =LARGE() function finds the kth largest number in an array.

I need to build a formula that finds the kth largest number in an array - when the number ends with a specified digit.

Data like this:
11
51
31
21
41
would give the result 51, if I'm looking for numbers ending in 1.
This:
7
27
47
87
would return 87, if I want a number ending in 7.

Finally, data like this:
11
23
34
89
27
16
would return 16, if I'm searching for the largest number ending in 6.

I'd like to do this without writing a custom function in VBA.

Any suggestions?
 
Last edited:

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

schielrn

Well-known Member
Joined
Apr 4, 2007
Messages
6,939
Maybe try this:

=LARGE(IF(RIGHT(G1:G100,1)="6",G1:G100),1)

This needs to be confirmed with control+shift+enter and not just enter.

Hope that helps.
 

Chris The Rock

Active Member
Joined
Feb 24, 2002
Messages
287
Maybe try this:

=LARGE(IF(RIGHT(G1:G100,1)="6",G1:G100),1)

This needs to be confirmed with control+shift+enter and not just enter.

Hope that helps.

An array formula is almost certainly what I need, but that formula doesn't work because it's comparing text values (RIGHT) with numeric values (LARGE). However, it gives me a good place to start.

Thanks!
 

Chris The Rock

Active Member
Joined
Feb 24, 2002
Messages
287
An array formula is almost certainly what I need, but that formula doesn't work because it's comparing text values (RIGHT) with numeric values (LARGE). However, it gives me a good place to start.

Thanks!

I just stuck a "1*" in front of the IF statement and it does just what I want.
 

schielrn

Well-known Member
Joined
Apr 4, 2007
Messages
6,939

ADVERTISEMENT

An array formula is almost certainly what I need, but that formula doesn't work because it's comparing text values (RIGHT) with numeric values (LARGE). However, it gives me a good place to start.

Thanks!
Not sure what you mean? I put ="6" so it looked at a text value, but you could also use:

=LARGE(IF(RIGHT(G1:G100,1)+0=6,G1:G100),1)

But everything in the list would need to be a number?
 

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
maybe:

=LARGE(IF(MOD(G1:G100,10)=6,G1:G100),1)

Confirm with Ctrl+Shift+Enter

Denis
 

Chris The Rock

Active Member
Joined
Feb 24, 2002
Messages
287
Not sure what you mean? I put ="6" so it looked at a text value, but you could also use:

=LARGE(IF(RIGHT(G1:G100,1)+0=6,G1:G100),1)

But everything in the list would need to be a number?

Everything works, but it was necessary for everything in the list to be a number.

Thank you everyone for jogging my memory and helping me solve this mystery.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,046
Messages
5,639,758
Members
417,109
Latest member
996

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
Top