Index Match and Arrays

J_Kelly

New Member
Joined
Feb 25, 2022
Messages
7
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have the below formula, its functions normally and returns the relevant cell data however when a members name is duplicated in column E but they are in different Crew numbers which is correct. The issue I'm running into is this member e.g. John Smith, is in both Crew 1 and Crew 4 in different locations, the locations appear on the sheet in alphabetical so they appear in Crew 4 prior to Crew 1, the index runs and triggers the Crew 1 calculation on the Crew 4 therefore returning 'Crew 3' and not the location

=IF(COUNTIFS($B:$B,"Crew 1",$E:$E,$AB514)>=1,INDEX($B:$B,MATCH($AB514,$E:$E,0)-2,,1),
IF(COUNTIFS($B:$B,"Crew 2",$E:$E,$AB514)>=1,INDEX($B:$B,MATCH($AB514,$E:$E,0)-4,,1),
IF(COUNTIFS($B:$B,"Crew 3",$E:$E,$AB514)>=1,INDEX($B:$B,MATCH($AB514,$E:$E,0)-6,,1),
IF(COUNTIFS($B:$B,"Crew 4",$E:$E,$AB514)>=1,INDEX($B:$B,MATCH($AB514,$E:$E,0)-8,,1)))))

Is there a way to prioritise the doing the calculation based off of the location of 'Crew 1' or whichever is first i.e Crew 4 and running the appropriate calculation first?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi,

I have the below formula, its functions normally and returns the relevant cell data however when a members name is duplicated in column E but they are in different Crew numbers which is correct. The issue I'm running into is this member e.g. John Smith, is in both Crew 1 and Crew 4 in different locations, the locations appear on the sheet in alphabetical so they appear in Crew 4 prior to Crew 1, the index runs and triggers the Crew 1 calculation on the Crew 4 therefore returning 'Crew 3' and not the location

=IF(COUNTIFS($B:$B,"Crew 1",$E:$E,$AB514)>=1,INDEX($B:$B,MATCH($AB514,$E:$E,0)-2,,1),
IF(COUNTIFS($B:$B,"Crew 2",$E:$E,$AB514)>=1,INDEX($B:$B,MATCH($AB514,$E:$E,0)-4,,1),
IF(COUNTIFS($B:$B,"Crew 3",$E:$E,$AB514)>=1,INDEX($B:$B,MATCH($AB514,$E:$E,0)-6,,1),
IF(COUNTIFS($B:$B,"Crew 4",$E:$E,$AB514)>=1,INDEX($B:$B,MATCH($AB514,$E:$E,0)-8,,1)))))

Is there a way to prioritise the doing the calculation based off of the location of 'Crew 1' or whichever is first i.e Crew 4 and running the appropriate calculation first?
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,146
Members
449,098
Latest member
Doanvanhieu

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