Find the cell range of the cells containing the same (string) values in a sorted column and pass it to a MIN function

Jiinglelocks

New Member
Joined
Jun 7, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello, I'm not sure if I'm asking my question correctly but hopefully I can make it clear. This is an example of my data:
1623091553624.png


I have animal names, a distance in meters and a "closest" column, in which I need to display a "Y" next to the minimum distance of that group (so the minimum distance of the Adder distances, the minimum distance of the American Mink distances and so on...).

I have this formula working which applies to a cell range that I pre-define, this is for Adders:
1623091664042.png


But I need the range to be dynamic. Ideally excel or VBA would figure out that "Adder" is contained in the range A2:A12 and find the minimum value in the same range of the adjacent column. I have hundreds of animal names to go through so I can't really add the names individually. Is what I'm asking possible?

Thank you for your time!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try

Excel Formula:
=IF(B2=MINIFS(B:B,A:A,A2),"Y","")

Or, if you can sort by name and distance, then
Excel Formula:
=IF(A2=A1,"",B2)
should work.
 
Upvote 0
Solution
@jasonb75 thank you for this, the MINIFS snippet works perfectly! Would you mind explaining how it works? I tried something like this with MINIFS but since I'm new to programming/excel formulae in general I couldn't quite sort it out.
 
Upvote 0
The MINIFS part is looking for the distance for the common name on the current row, if you entered it alone, =MINIFS(B:B,A:A,A2) then it would give the minimum distance for 'Adder' in every cell from C2 to C12. By using IF to compare that result to the distance in the current row we can determine if that row holds the minimum distance, or if it contains something else and return either "Y" or "" (blank) accordingly.
 
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