NOTFOUND

NOTFOUND(Array,Search_Value,[Case_Sensitive])
Array
Required. Range to check if cells don't contain a value
Search_Value
Required. Value to look for in array
[Case_Sensitive]
Optional. 1=search is case sensitive; 0 or ignored=not

NOTFOUND returns TRUE or FALSE if a cell in a given range does not contain a value.

schardt679

Board Regular
Joined
Mar 27, 2021
Messages
58
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
NOTFOUND returns TRUE or FALSE if a cell in a given range does not contain a value.

Search can made case sensitive but isn't by default.
Other functions on minisheet: AFORMULATEXT.

=NOTFOUND(Array☛ range to check if cells don't contain a value, Search_Value☛ value to look for in array, [Case_Sensitive]☛ 1=search is case sensitive; 0/❎=is not)
⁂[]=optional; ✅=default; ❎=omit

Excel Formula:
=LAMBDA(Array,Search_Value,[Case_Sensitive],
      LET(Arr, Array,          Val, Search_Value,          Case, Case_Sensitive,
             ArrScan, ISOMITTED(Arr),          ArrMSG, "Array required",
             ValScan, ISOMITTED(Val),          ValMSG, "Search_Value required",
             CaseScan, AND(Case<>{1,0}),          CaseMSG, "Case=1,0",
             ERRORS, IFS(ArrScan, ArrMSG,  ValScan, ValMSG,  CaseScan, CaseMSG,  1, 0),
             SearchCase, SEARCH(Val, Arr),          FindCase, FIND(Val, Arr),
             Result, --(ISNUMBER(IF(Case, FindCase,  SearchCase)))=0,
             Return, IF(ERRORS<>0, ERRORS,  Result),
             Return
      )
  )
LAMBDA Examples.xlsx
ABCDEFGHIJ
1NOTFOUND
2
3Original DataSearch_ValueCase_SensitiveResult
4My name is Patrick.I went to CalU of PA. 0FALSEFALSE
5#N/ATRUETRUE
6I have 3 degrees.I am 28.FALSEFALSE
7I graduated in:2017FALSETRUE
8
9Search_Value is " "
10Not Case Sensitive
11Formula in cell H4☛ =NOTFOUND(B4:C7, E4, F4)
12
13
14
15Original DataSearch_ValueCase_SensitiveResult
16AlexM1TRUE
17CarterTRUE
18PaulaTRUE
19LydiaTRUE
20Mary MFALSE
21Mary McFALSE
22MikeFALSE
23ShellyTRUE
24TaylorTRUE
25WilliamTRUE
26
27Search_Value is "M"
28Case Sensitive
29Formula in cell H16☛ =NOTFOUND(B16:B25, E16, F16)
30
31
32
33Original DataSearch_ValueCase_SensitiveResult
34AlexM0TRUE
35CarterTRUE
36PaulaTRUE
37LydiaTRUE
38Mary MFALSE
39Mary McFALSE
40MikeFALSE
41ShellyTRUE
42TaylorTRUE
43WilliamFALSE
44
45Search_Value is "M"
46Not Case Sensitive
47Formula in cell H34☛ =NOTFOUND(B34:B43, E34, F34)
48
49
50
51Original DataSearch_ValueCase_SensitiveResult
52(164) 507-0693(717) 361-232625TRUETRUE
53(193) 593-0165(718) 984-1786TRUETRUE
54(278) 525-2728(780) 530-9377FALSETRUE
55(392) 325-8368(828) 702-9706FALSETRUE
56(452) 762-9224(914) 877-8008TRUETRUE
57(466) 956-7649(917) 675-2878TRUETRUE
58(491) 862-9999(926) 506-1689TRUETRUE
59(501) 993-9565(982) 419-5562TRUETRUE
60(545) 216-3867(986) 334-2317TRUETRUE
61(638) 105-4749(992) 475-8319TRUETRUE
62
63Search_Value is "25"
64Not Case Sensitive
65Formula in cell H52☛ =NOTFOUND(B52:C61, E52, F52)
66
NOTFOUND
Cell Formulas
RangeFormula
H4:I7H4=NOTFOUND(B4:C7, E4, F4)
B11B11=AFORMULATEXT(H4)
H16:H25,H34:H43H16=NOTFOUND(B16:B25, E16, F16)
B29,B65,B47B29=AFORMULATEXT(H16)
H52:I61H52=NOTFOUND(B52:C61, E52, F52)
Dynamic array formulas.
 
Upvote 0
On second thought, I eliminated the error checking for the required values. Excel formulas already return errors if you are missing required arguments. This should speed of calculation time.

Excel Formula:
=LAMBDA(Array,Search_Value,[Case_Sensitive],
      LET(Arr, Array,          Val, Search_Value,          Case, Case_Sensitive,
             CaseScan, AND(Case<>{1,0}),          CaseMSG, "Case=1,0",
             SearchCase, SEARCH(Val, Arr),          FindCase, FIND(Val, Arr),
             Result, --(ISNUMBER(IF(Case, FindCase,  SearchCase)))=0,
             Return, IF(CaseScan, CaseMSG,  Result),
             Return
      )
  )
 
This has been updated again. It now has 3 match types (fuzzy/ partial --> 0, from left/ start --> 1, & exact --> 2 with each type having the ability to be case sensitive. Currently this only supports one search value. The array can be 1 dimensional or 2 dimensional.

I am looking to improve this in two ways:
1. Allow for multiple search values
2. Shorten the code

I know someone on here will be able to find a solution that does both of those things. Any help would be greatly appreciated.

Excel Formula:
= LAMBDA(Array, Search_Value, [Match_Type], [Case_Sensitive],
    LET(
        Arr, Array,
        Val, Search_Value,
        Type, IFERROR(--(Match_Type), 3),
        Case, IFERROR(--(Case_Sensitive), 2),
        TypeScan, OR(Type < 0, Type > 2),
        TypeMSG, "Match_Type=0,1,2",
        CaseScan, AND(Case <> {0, 1}),
        CaseMSG, "Case_Sensitive=0,1",
        ERRORS, IFS(TypeScan, TypeMSG, CaseScan, CaseMSG, 1, 0),
        FuzzCS, FIND(Val, Arr),
        FuzzNCS, SEARCH(Val, Arr),
        LeftChar, LEFT(Arr, LEN(Val)),
        StartCS, EXACT(LeftChar, Val),
        StartNCS, LeftChar = Val,
        SameCS, EXACT(Arr, Val),
        SameNCS, Arr = Val,
        Fuzz, ISNUMBER(IF(Case, FuzzCS, FuzzNCS)),
        Start, IF(Case, StartCS, StartNCS),
        Same, IF(Case, SameCS, SameNCS),
        Result, --(SWITCH(Type, 1, Start, 2, Same, Fuzz)) = 0,
        Return, IF(ERRORS <> 0, ERRORS, Result),
        Return
    )
)
 
Below is my solution for part 1 (multiple search values across 2D ranges). It is quite long but includes error checking and quite a few variable names to make it easier to understand. The basic idea is converts the search array to a 1-column array and the value array to a 1-row array. This allows MMULT to return an array of trues & falses regarding the search values based on the match type & case sensitivity. Then the resulting array is converted back to the original size. Finally the code checks for errors before returning the results.

Excel Formula:
= LAMBDA(Array,Search_Value,[Match_Type],[Case_Sensitive],
    LET(
        Arr, Array,
        Val, TOCOL(Search_Value),
        Fnd, Found?,
        Type, IFERROR(--(Match_Type),  3),
        Case, IFERROR(--(Case_Sensitive),  2),
        TypeScan, OR(Type < 0, Type > 2),
        TypeMSG, "Match_Type=0,1,2",
        CaseScan, AND(Case <> {0,1}),
        CaseMSG, "Case_Sensitive=0,1",
        ERRORS, IFS(TypeScan, TypeMSG,  CaseScan, CaseMSG,  1, 0),
        ColCt, CELLCT(Arr, 2),
        RowCt, CELLCT(Val, 1),
        Seq_1, SEQUENCE(RowCt,,, 0),
        ArrCol, TOCOL(Arr),
        ValRow, TOROW(Val),
        FuzzCS, FIND(ValRow, ArrCol),
        FuzzNCS, SEARCH(ValRow, ArrCol),
        LeftChar, LEFT(ArrCol, LEN(ValRow)),
        StartCS, EXACT(LeftChar, ValRow),
        StartNCS, LeftChar = ValRow,
        SameCS, EXACT(ArrCol, ValRow),
        SameNCS, ArrCol = ValRow,
        Fuzz, ISNUMBER(IF(Case, FuzzCS,  FuzzNCS)),
        Start, IF(Case, StartCS,  StartNCS),
        Same, IF(Case, SameCS,  SameNCS),
        TypeSel, SWITCH(Type,  1, Start,  2, Same,  Fuzz),
        TruFal, --(MMULT(--(TypeSel), Seq_1))=0,
        Result, WRAPROWS(TruFal, ColCt),
        Return, IF(ERRORS <> 0, ERRORS,  Result),
        Return
    )
)
 

Forum statistics

Threads
1,224,836
Messages
6,181,250
Members
453,026
Latest member
cknader

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