Look if values exist seperately and together, then write Yes or No in cell

MasterBash

Board Regular
Joined
Jan 22, 2022
Messages
63
Office Version
  1. 365
Platform
  1. Windows

Hello,

Table exemple on Sheet1 :
1000...23171000 2317
1001...11871001 1187
1002...5996, 96661002 5996, 9666
1003...48621003 4862



Currently, I have this formula :
Excel Formula:
=IF(VLOOKUP(A2&" "&C2;'Sheet1'!D:D;1;FALSE)>0;"Yes";"No")
So it lookups value A2 and C2 in my current sheet, and if it is equal to column D on Sheet1, then Yes.

2 problems in the last 2 rows :
Third row : When there are 2 numbers in column C of sheet1. So 1002 5996, 9666 returns false even if both are available. Sometimes those numbers can be seperated by a comma, sometimes by a dash or other times, simply a space. Sometimes it is also like this : 1002 9666, 5996. It needs to work with 1 or more numbers, as long as those numbers are exact, regardless of the seperators.
Fourth row : By mistake, sometimes user enter extra spaces before/after the numberm resulting in a "No".

How can I modify my formula to make sure that those 2 cases are equal to Yes ?
Unfortunately, VBA is not an option.
Thank you !
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try:

Excel Formula:
=IF(COUNTIF(D:D;TRIM(A4)&" "&TRIM(C4));"Yes";"No")
 
Upvote 0
I just tested it out and unfortunately, I do not get the desired results. I think I am trying to do too much with the formula. I will try to keep it simple and I think this will fix 50% of the problems we are having:

1002 5996
1002 9666

on Sheet2, but 1002 5996, 9666 on sheet1.
or it can also be reversed like 1002 9666, 5996.
Is there a formula to make those say Yes, that would be nice instead of No with my current formula, regardless of the seperator ?

Thank you.
 
Upvote 0
See if this helps. It should be better for your row 4 and might fix a few more of your row 3 - it can't fix all of those because you have varying characters between the numbers and/or some numbers missing.

Excel Formula:
=IF(COUNTIFS(D:D,"=" &TRIM(A2 & " " & C2)&"*"),"Yes","No")
 
Upvote 0
I'm not understanding how you have the data on sheet1 and how on sheet2.
You could put about 10 examples with problems of the data on sheet1 and the data on sheet2.
Use the XL2BB tool.
 
Upvote 0
Here is an example of what I am trying to do.... The column "Expected result" is what it should be.

numbertest.xlsx
ABCD
1OrderAttributionNumberHelper
2100010007788910001000 77889
3100010011533, 157710001001 1533, 1577
410001002194410001002 1944
5100010032007-213810001003 2007-2138
61000100410001004
7200010005228, 633920001000 5228, 6339
8200010015228, 633920001001 5228, 6339
9200010024444, 4588, 468820001002 4444, 4588, 4688
10200010034444, 4588, 468820001003 4444, 4588, 4688
1120001004666620001004 6666
12200010059998-999920001005 9998-9999
1330001000570030001000 5700
1430001003590030001003 5900
Sheet1
Cell Formulas
RangeFormula
D2:D14D2=A2&" "&C2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A14Cell ValueduplicatestextNO


Sheet1 has a helper column as a formula.

numbertest.xlsx
ABCDEF
1OrderOrder available ?NumberNumber available ?Exact ?Expected result
210001000Yes77889YesYesEverything is yes, as it should be
310001001Yes1533#N/AYesEverything should be yes
410001001Yes1577#N/AYesEverything should be yes
510001002Yes1944YesYesEverything is yes, as it should be
610001003Yes2007#N/AYesEverything should be yes
710001003Yes2138#N/AYesEverything should be yes
830001000Yes5600#N/A#N/AThat is correct, wrong load# on Sheet1
930001002#N/A5900Yes#N/AThat is correct, order does not exist on Sheet1
Sheet2
Cell Formulas
RangeFormula
D2:D9,B2:B9D2=IF(VLOOKUP(C2,Sheet1!C:C,1,FALSE)>0,"Yes","No")
E2:E9E2=IF(VLOOKUP(A2&"*"&C2&"*",Sheet1!D:D,1,FALSE)>0,"Yes","No")


numbertest.xlsx
ABCDEF
1OrderOrder available ?NumberNumber available ?Exact ?Expected result
220001000-20001001#N/A5008#N/A#N/AEverything should be yes
320001000-20001001#N/A6339#N/A#N/AEverything should be yes
420001002-20001003#N/A4444#N/A#N/AEverything should be yes
520001002-20001003#N/A4588#N/A#N/AEverything should be yes
620001002-20001003#N/A4688#N/A#N/AEverything should be yes
720001004Yes6666YesYesEverything is yes, as it should be
820001005Yes9998#N/A#N/AEverything should be yes
920001005Yes9999#N/A#N/AEverything should be yes
Sheet3
Cell Formulas
RangeFormula
D2:D9,B2:B9D2=IF(VLOOKUP(C2,Sheet1!C:C,1,FALSE)>0,"Yes","No")
E2:E9E2=IF(VLOOKUP(A2&" "&C2,Sheet1!D:D,1,FALSE)>0,"Yes","No")


Sheet2 and Sheet3 can have different formulas, as long as it works.
B looks up if Order# exists on Sheet1, Yes if it is.
D looks up if Number exists on Sheet1, Yes if it is.
E looks up if column A and C matches with the ones on Sheet1 (Helper column D), yes if it is.

Problems exist when there are 2 orders on the same number or when there are 2 numbers for the same order.

For the extra spaces, - and comma, I can just use the find/replace tool if necessary. The problem above is mainly what I am trying to fix.

Thank you.
 
Upvote 0
Try this. I didn't use the Helper column.
Book1
ABCD
1OrderAttributionNumberHelper
2100010007788910001000 77889
310001001 1533, 157710001001 1533, 1577
410001002194410001002 1944
5100010032007-213810001003 2007-2138
61000100410001004
7200010005228, 633920001000 5228, 6339
8200010015228, 633920001001 5228, 6339
9200010024444, 4588, 468820001002 4444, 4588, 4688
10200010034444, 4588, 468820001003 4444, 4588, 4688
1120001004666620001004 6666
12200010059998-999920001005 9998-9999
1330001000570030001000 5700
1430001003590030001003 5900
Sheet1
Cell Formulas
RangeFormula
D2:D14D2=A2&" "&C2

Book1
ABCDE
1OrderOrder available ?NumberNumber available ?Exact ?
210001000Yes77889YesYes
310001001Yes1533YesYes
410001001Yes1577YesYes
510001002Yes1944YesYes
610001003Yes2007YesYes
710001003Yes2138YesYes
830001000Yes5600NoNo
930001002No5900YesNo
Sheet2
Cell Formulas
RangeFormula
D2:D9D2=IF(SUM(--ISNUMBER(SEARCH(C2&", ",SUBSTITUTE(Sheet1!$C$2:$C$14,"-",", ")&", ")))>0,"Yes","No")
E2:E9E2=IF(B2&D2="YesYes","Yes","No")
B2:B9B2=IF(COUNTIF(Sheet1!A:A,A2),"Yes","No")

Book1
ABCDE
1OrderOrder available ?NumberNumber available ?Exact ?
220001000-20001001Yes5008NoNo
320001000-20001001Yes6339YesYes
420001002-20001003Yes4444YesYes
520001002-20001003Yes4588YesYes
620001002-20001003Yes4688YesYes
720001004Yes6666YesYes
820001005Yes9998YesYes
920001005Yes9999YesYes
Sheet3
Cell Formulas
RangeFormula
D2:D9D2=IF(SUM(--ISNUMBER(SEARCH(C2&", ",SUBSTITUTE(Sheet1!$C$2:$C$14,"-",", ")&", ")))>0,"Yes","No")
E2:E9E2=IF(B2&D2="YesYes","Yes","No")
B2:B9B2=IF(SUM(COUNTIF(Sheet1!A:A,TEXTSPLIT(Sheet3!A2,"-")))>0,"Yes","No")
 
Upvote 0
Solution
Unfortunately, this will be viewed online only, where VBA macros don't work.

OK. I will look for another option with the formulas.

Hi @Cubist , that way the order and number can exist but not necessarily on the same row and the search should verify that they are on the same row.
And I also imagine that the data from sheets 2 and 3 can be on the same sheet, something like this, @MasterBash or am I wrong?


varios 23jul2024.xlsm
AB
1OrderNumber
21000100077889
3100010011533
4100010011577
5100010021944
6100010032007
7100010032138
8300010005600
9300010025900
1020001000-200010015008
1120001000-200010016339
1220001002-200010034444
1320001002-200010034588
1420001002-200010034688
15200010046666
16200010059998
17200010059999
Sheet2
 
Upvote 0

Forum statistics

Threads
1,223,869
Messages
6,175,088
Members
452,611
Latest member
bls2024

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