Xlookup or similar

djjamesp

New Member
Joined
Oct 21, 2024
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi all, I'm trying to get the following sheet to return one of four possible outcomes, but no matter what I try it doesn't quite work. I've also tried to upload the mini sample sheet but due to work restrictions on my works laptop it will not allow me to install the add-in.

- C5:8000 and M5:8000 will both contain the same unique ref numbers, but on different rows
- Column J on the same row as column C will have a yes, no or N/A value
- Column R on the same row as Column M will contain a value or blank
- If column J is Yes and M has a value return 'OKAY'
- If column J is No or N/A and M has a value return 'TECH ERROR'
- If column J is Yes and M has no value return "ENGINEER FAILED'
- if column J is No and M has no value return 'NOT REQUIRED'

examples
- C5 & M9 match, J5=Yes & M=Yes this will return 'OKAY'
- C12 & M14 match, J12=No & M14=No this will return 'NOT REQUIRED'

The two ways I went about this so far are

=IF(AND(COUNTIF(M5:M$8000, C1) > 0, J1 = "Yes", NOT(ISBLANK(INDEX(R:R, MATCH(C1, M:M, 0))))), "OKAY", IF(AND(COUNTIF(M:M, C1) > 0, J1 = "No", NOT(ISBLANK(INDEX(R:R, MATCH(C1, M:M, 0))))), "TECH ERROR", IF(AND(COUNTIF(M:M, C1) > 0, J1 = "Yes", ISBLANK(INDEX(R:R, MATCH(C1, M:M, 0)))), "ENGINEER FAILED", IF(AND(COUNTIF(M:M, C1) > 0, J1 = "No", ISBLANK(INDEX(R:R, MATCH(C1, M:M, 0)))), "NOT REQUIRED", ""))))

and

=IFERROR( IF(J5="Yes", IF(NOT(ISBLANK(XLOOKUP(C5, M$5:M$8000, R$5:R$8000, "", 0))), "OKAY", "ENGINEER FAILED"), IF(NOT(ISBLANK(XLOOKUP(C5, M$5:M$8000, R$5:R$8000, "", 0))), "TECH ERROR", "NOT REQUIRED") ), ""

I've spent a couple of days on this so far and I'm struggling!

Any help is greatly appreciated

Thanks in advance

James
 

Attachments

  • Sample Data.PNG
    Sample Data.PNG
    195 KB · Views: 5

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
examples
- C5 & M9 match, J5=Yes & M=Yes this will return 'OKAY'
- C12 & M14 match, J12=No & M14=No this will return 'NOT REQUIRED'
The above does not make sense to me since you said (& your image confirms) that M contains ref numbers, not Yes or No
M5:8000 will both contain the same unique ref numbers


However, perhaps this is the sort of thing you are after?

24 10 30.xlsm
CJKMRYZ
5Ref 1YesRef 23ENGINEER FAILED
6Ref 2NoRef 3TECH ERROR
7Ref 3N/ARef 42NOT REQUIRED
8Ref 4NoRef 55TECH ERROR
9Ref 5YesRef 1OKAY
10Ref 6YesRef 65OKAY
Outcomes
Cell Formulas
RangeFormula
Z5:Z10Z5=LET(m,XLOOKUP(C5,M$5:M$10,R$5:R$10),IF(J5="Yes",IF(m="","ENGINEER FAILED","OKAY"),IF(m="","NOT REQUIRED","TECH ERROR")))
 
Upvote 0
I've played with the syntax a little but it still doesn't give the correct results, I've simplified my example spreadsheet down significantly and I realised the error of my original example - I hadn't updated the 'results' to reflect how I wanted it to display, (sincere apologies, I can see why that confused anyone) please see the example below of what I want to achieve.

Column M is the starting reference point

1730305719801.png
 
Upvote 0
Column M is the starting reference point
We didn't have that information before. :)
I think that my previous formula was basically correct but it put the results on the row with the Job Number in column C rather than on the row with the job number in column M. The change makes the formula bit simpler.
:oops: Also, I did use col R instead of Q so have fixed that
Another change is that you have changed from "TECH ERROR" to "TECH FAILED"
Given all that, see how this version goes.

24 10 30.xlsm
CJKMNOPQXYZ
5SR/19200YesSR/19207ENGINEER FAILED
6SR/19201NoSR/19206C17TECH FAILED
7SR/19202YesSR/19205B07OKAY
8SR/19203NoSR/19204NOT REQUIRED
9SR/19204NoSR/19203NOT REQUIRED
10SR/19205YesSR/19202A01OKAY
11SR/19206NoSR/19201NOT REQUIRED
12SR/19207YesSR/19200ENGINEER FAILED
Outcomes (2)
Cell Formulas
RangeFormula
Z5:Z12Z5=IF(XLOOKUP(M5,C$5:C$12,J$5:J$12)="Yes",IF(Q5="","ENGINEER FAILED","OKAY"),IF(Q5="","NOT REQUIRED","TECH FAILED"))
 
Upvote 0
That is perfect, apologies for all the confusion - this is a live spreadsheet and I'm working on it constantly adding and removing things so some of the cell references have got mixed up. Wow, you don't know how much relief that's given me! Thank you so much!!
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,223,883
Messages
6,175,167
Members
452,615
Latest member
bogeys2birdies

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