Search multiple exact strings in multiple columns

Sebastian P

New Member
Joined
Mar 6, 2024
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hello everyone,

I am new to this forum so pardon me if broke any rules through this post.

As the subject of the post states, I am trying to search multiple exact strings in multiple columns. Meaning in the attached file I am searching for certain strings (group names) in a range of cells (multiple columns)

The groups are as per below details:

PUBLIC
GTIS CMUK Windows Approval
GTIS CMUK Windows
UNIX-SUPPORT-FR
MIT Windows
MIT Unix
MIT Windows Approval
MIT Unix Approval
GTIS Hosting Platform Windows

PRIVATE
GTIS Hosting Platform Taurus Approval
GTIS Hosting Platform Taurus
GTIS Hosting Platform Atlas
GTIS Hosting Platform Atlas Approval

The formula I used is:
=IF(OR(ISNUMBER(SEARCH({"GTIS CMUK Windows Approval","GTIS CMUK Windows","UNIX-SUPPORT-FR","MIT Windows","MIT Unix","MIT Windows Approval","MIT Unix Approval","GTIS Hosting Platform Windows"},Table2[@[Group 1]:[Group 6]]))),"PUBLIC",IF(OR(ISNUMBER(SEARCH({"GTIS Hosting Platform Taurus Approval","GTIS Hosting Platform Taurus","GTIS Hosting Platform Atlas","GTIS Hosting Platform Atlas Approval"},Table2[@[Group 1]:[Group 6]]))),"PRIVATE","NONE"))

I have the following points for which I would need support:
1. Is the formula looking in the entire array A2 to A17, by using Table2[@[Group 1]:[Group 6]] in the syntax? I am asking this because:
------>The value returned in cells G4-G8 should be PUBLIC, but the formula does not find a match, though the UNIX-SUPPORT-FR group is in the PUBLIC category

2. How can adapt the formula to search for an exact match. From what I managed to figure out, because the formula does not look for an exact match, the following happens

------>The value in G9-G17 should be PRIVATE, but because the formula does not searches for an exact match, it returns PUBLIC
------>This happens because in one of the Group1 to Group 6 column there is a partial match of the searched text (bolded in below
------>"GTIS Hosting Platform Windows" -->this is PRIVATE
------>"GTIS Hosting Platform Atlas Approval"-->this should be PUBLIC

Thank you in advance,

Column A Column B Column C Column D Column E Column F Column G
Group 1 Group 2 Group 3 Group 4 Group 5 Group 6 Group Category
GTIS Hosting Platform Atlas Approval GTIS Hosting Platform Atlas ` GTIS CMUK Windows Approval GTIS CMUK Windows GTIS CMUK Windows NONE
GTIS Hosting Platform Atlas Approval GTIS Hosting Platform Atlas GTIS Hosting Platform Atlas GTIS CMUK Windows Approval GTIS CMUK Windows GTIS CMUK Windows PRIVATE
APP-SRE-EI APP-SRE-EI APPOPSFLS-EIKON APP-SRE-EI UNIX-SUPPORT-FR APPOPSFLS-EIKON NONE
APP-SRE-EI APP-SRE-EI APPOPSFLS-EIKON APP-SRE-EI UNIX-SUPPORT-FR APPOPSFLS-EIKON NONE
APP-SRE-EI APP-SRE-EI APPOPSFLS-EIKON APP-SRE-EI UNIX-SUPPORT-FR APPOPSFLS-EIKON NONE
APP-SRE-EI APP-SRE-EI APPOPSFLS-EIKON APP-SRE-EI UNIX-SUPPORT-FR APPOPSFLS-EIKON NONE
APP-SRE-EI APP-SRE-EI APPOPSFLS-EIKON APP-SRE-EI UNIX-SUPPORT-FR APPOPSFLS-EIKON NONE
GTIS Hosting Platform Taurus Approval GTIS Hosting Platform Taurus GTIS Hosting Platform Taurus MIT Windows Approval MIT Windows MIT Windows PUBLIC
GTIS Hosting Platform Taurus Approval GTIS Hosting Platform Taurus GTIS Hosting Platform Taurus MIT Unix Approval MIT Unix MIT Unix PUBLIC
GTIS Hosting Platform Taurus Approval GTIS Hosting Platform Taurus GTIS Hosting Platform Taurus MIT Windows Approval MIT Windows MIT Windows PUBLIC
GTIS Hosting Platform Taurus Approval GTIS Hosting Platform Taurus GTIS Hosting Platform Taurus MIT Unix Approval MIT Unix MIT Unix PUBLIC
GTIS Hosting Platform Taurus Approval GTIS Hosting Platform Taurus GTIS Hosting Platform Taurus MIT Windows Approval MIT Windows MIT Windows PUBLIC
GTIS Hosting Platform Taurus Approval GTIS Hosting Platform Taurus GTIS Hosting Platform Taurus MIT Windows Approval MIT Windows MIT Windows PUBLIC
GTIS Hosting Platform Taurus Approval GTIS Hosting Platform Taurus GTIS Hosting Platform Taurus MIT Unix Approval MIT Unix MIT Unix PUBLIC
GTIS Hosting Platform Taurus Approval GTIS Hosting Platform Taurus GTIS Hosting Platform Taurus MIT Windows Approval MIT Windows MIT Windows PUBLIC
GTIS Hosting Platform Taurus Approval GTIS Hosting Platform Taurus GTIS Hosting Platform Taurus MIT Windows Approval MIT Windows MIT Windows PUBLIC
 

Attachments

  • Example.PNG
    Example.PNG
    60.9 KB · Views: 14

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Welcome to the Forum!

A simpler example, to illustrate why your formula is failing. Here, we're comparing four columns to six, hence two #N/A columns in the results. Occasionally you get lucky when the values line up - e.g. when "r", the third term of your search, is in column 3.

ABCDEFGHIJKLM
1
2BlahBlahBlahBlahBlahBlah#VALUE!#VALUE!#VALUE!#VALUE!#N/A#N/A
3BlahBlahrBlahBlahBlah#VALUE!#VALUE!1#VALUE!#N/A#N/A
4BlahBlahBlahrBlahBlah#VALUE!#VALUE!#VALUE!#VALUE!#N/A#N/A
Sheet1
Cell Formulas
RangeFormula
H2:M4H2=SEARCH({"p","q","r","s"},A2:F2)
Dynamic array formulas.


Here's another way you could do this:

ABCDEFGHIJ
1Group 1Group 2Group 3Group 4Group 5Group 6StatusPublicPrivate
2MIT Windows approvalBlahBlahBlahBlahBlahPublicGTIS CMUK Windows ApprovalGTIS Hosting Platform Taurus Approval
3BlahGTIS Hosting Platform TaurusMIT WindowsBlahBlahBlahPublicGTIS CMUK WindowsGTIS Hosting Platform Taurus
4BlahBlahGTIS Hosting Platform TaurusBlahBlahBlahPrivateUNIX-SUPPORT-FRGTIS Hosting Platform Atlas
5BlahBlahBlahBlahBlahBlahNoneMIT WindowsGTIS Hosting Platform Atlas Approval
6MIT Unix
7MIT Windows Approval
8MIT Unix Approval
9GTIS Hosting Platform Windows
10
Sheet1
Cell Formulas
RangeFormula
G2:G5G2=IF(OR(COUNTIF(Table2[@[Group 1]:[Group 6]],Public)),"Public",IF(OR(COUNTIF(Table2[@[Group 1]:[Group 6]],Private)),"Private","None"))
Named Ranges
NameRefers ToCells
Private=Sheet1!$J$2:$J$5G2:G5
Public=Sheet1!$I$2:$I$9G2:G5
 
Last edited:
Upvote 0
Hi Stephen,

Thx so much for the answer. I have used Tables instead of Named Ranges, but indeed, much cleaner/readable/understandable formula.

I am still facing an issue, for which I have found a workaround, but not sure is the best solution.

I have used the following two formulas:

Group Category 1 --> formula used: =IF(OR(COUNTIF(Table2[@[Group 1]:[Group 6]],PUBLIC)),"PUBLIC",IF(OR(COUNTIF(Table2[@[Group 1]:[Group 6]],PRIVATE)),"PRIVATE","NONE"))

Group Category 2 --> formula used: =IF(OR(COUNTIF(Table2[@[Group 1]:[Group 3]],PUBLIC)),"PUBLIC",IF(OR(COUNTIF(Table2[@[Group 1]:[Group 3]],PRIVATE)),"PRIVATE",IF(OR(COUNTIF(Table2[@[Group 4]:[Group 6]],PUBLIC)),"PUBLIC",IF(OR(COUNTIF(Table2[@[Group 4]:[Group 6]],PRIVATE)),"PRIVATE","NONE"))))

and it returns as per below table:

Group 1
Group 2
Group 3
Group 4
Group 5
Group 6
Group Category 1
Group Category 2
GTIS Hosting Platform Atlas Approval
GTIS Hosting Platform Atlas
GTIS Hosting Platform Atlas
GTIS CMUK Windows Approval
GTIS CMUK Windows
GTIS CMUK Windows
PUBLIC
PRIVATE
GTIS Hosting Platform Atlas Approval
GTIS Hosting Platform Atlas
GTIS Hosting Platform Atlas
GTIS CMUK Windows Approval
GTIS CMUK Windows
GTIS CMUK Windows
PUBLIC
PRIVATE
APP-SRE-EI
APP-SRE-EI
APPOPSFLS-EIKON
APP-SRE-EI
UNIX-SUPPORT-FR
APPOPSFLS-EIKON
PUBLIC
PUBLIC
APP-SRE-EI
APP-SRE-EI
APPOPSFLS-EIKON
APP-SRE-EI
UNIX-SUPPORT-FR
APPOPSFLS-EIKON
PUBLIC
PUBLIC
GTIS Hosting Platform Taurus Approval
GTIS Hosting Platform Taurus
GTIS Hosting Platform Taurus
MIT Windows Approval
MIT Windows
MIT Windows
PUBLIC
PRIVATE
GTIS Hosting Platform Taurus Approval
GTIS Hosting Platform Taurus
GTIS Hosting Platform Taurus
MIT Unix Approval
MIT Unix
MIT Unix
PUBLIC
PRIVATE

My understanding as to why on rows 2, 3, 6, 7 there are different results between columns Group Category 1 and Group Category 2, is because the Group Category 1 formula takes one random value from any of the Group 1 to Group 6 values.
Group Category 2 formula, though probably also takes any random value, because there is a split of IFs (first looks in Group1 to Group3, and after it looks in Group4 to Group6) , it will return PRIVATE.

I am trying to understand if there is any way in which the formula can search in order from Group 1 to Group 6 and return PRIVATE or PUBLIC, based on first value found

Below are the Tables I used. First one named PRIVATE and the second one named PUBLIC

PRIVATE
GTIS Hosting Platform Taurus Approval
GTIS Hosting Platform Taurus
GTIS Hosting Platform Atlas
GTIS Hosting Platform Atlas Approval

PUBLIC
GTIS CMUK Windows Approval
GTIS CMUK Windows
UNIX-SUPPORT-FR
MIT Windows
MIT Unix
MIT Windows Approval
MIT Unix Approval
GTIS Hosting Platform Windows
 
Upvote 0
I think this is what you mean?

ABCDEFGHIJK
1Group 1Group 2Group 3Group 4Group 5Group 6StatusColumn1PublicPrivate
2MIT Windows approvalBlahBlahBlahBlahBlahPublicPublicGTIS CMUK Windows ApprovalGTIS Hosting Platform Taurus Approval
3BlahGTIS Hosting Platform TaurusMIT WindowsBlahBlahBlahPublicPrivateGTIS CMUK WindowsGTIS Hosting Platform Taurus
4BlahBlahGTIS Hosting Platform TaurusBlahBlahBlahPrivatePrivateUNIX-SUPPORT-FRGTIS Hosting Platform Atlas
5BlahBlahBlahBlahBlahBlahNoneNoneMIT WindowsGTIS Hosting Platform Atlas Approval
6MIT Unix
7MIT Windows Approval
8MIT Unix Approval
9GTIS Hosting Platform Windows
10
11Combined
12GTIS CMUK Windows ApprovalPublic
13GTIS CMUK WindowsPublic
14UNIX-SUPPORT-FRPublic
15MIT WindowsPublic
16MIT UnixPublic
17MIT Windows ApprovalPublic
18MIT Unix ApprovalPublic
19GTIS Hosting Platform WindowsPublic
20GTIS Hosting Platform Taurus ApprovalPrivate
21GTIS Hosting Platform TaurusPrivate
22GTIS Hosting Platform AtlasPrivate
23GTIS Hosting Platform Atlas ApprovalPrivate
Sheet1
Cell Formulas
RangeFormula
G2:G5G2=IF(OR(COUNTIF(Table2[@[Group 1]:[Group 6]],Public)),"Public",IF(OR(COUNTIF(Table2[@[Group 1]:[Group 6]],Private)),"Private","None"))
H2:H5H2=LET(p,VLOOKUP(Table2[@[Group 1]:[Group 6]],Combined,2,),TAKE(FILTER(p,ISTEXT(p),"None"),,1))
Named Ranges
NameRefers ToCells
Combined=Sheet1!$J$12:$K$23H2:H5
Private=Sheet1!$K$2:$K$5G2:G5
Public=Sheet1!$J$2:$J$9G2:G5
 
Upvote 0
Or with just the one lookup table:

ABCDEFGHIJK
1Group 1Group 2Group 3Group 4Group 5Group 6Status 1Status 2Combined
2MIT Windows approvalBlahBlahBlahBlahBlahPublicPublicGTIS CMUK Windows ApprovalPublic
3BlahGTIS Hosting Platform TaurusMIT WindowsBlahBlahBlahPublicPrivateGTIS CMUK WindowsPublic
4BlahBlahGTIS Hosting Platform TaurusBlahBlahBlahPrivatePrivateUNIX-SUPPORT-FRPublic
5BlahBlahBlahBlahBlahBlahNoneNoneMIT WindowsPublic
6MIT UnixPublic
7MIT Windows ApprovalPublic
8MIT Unix ApprovalPublic
9GTIS Hosting Platform WindowsPublic
10GTIS Hosting Platform Taurus ApprovalPrivate
11GTIS Hosting Platform TaurusPrivate
12GTIS Hosting Platform AtlasPrivate
13GTIS Hosting Platform Atlas ApprovalPrivate
Sheet1
Cell Formulas
RangeFormula
G2:G5G2=LET(p,IFERROR(VLOOKUP(Table2[@[Group 1]:[Group 6]],Combined,2,),""),IF(OR(p="Public"),"Public",IF(OR(p="Private"),"Private","None")))
H2:H5H2=LET(p,VLOOKUP(Table2[@[Group 1]:[Group 6]],Combined,2,),TAKE(FILTER(p,ISTEXT(p),"None"),,1))
Named Ranges
NameRefers ToCells
Combined=Sheet1!$J$2:$K$13G2:H5
 
Upvote 0
HI Stephen,

Thx once again. The H2 formula does what I needed.

Do you mind walking me through the formula a little bit, so I understand how it works?
 
Upvote 0
Do you mind walking me through the formula a little bit, so I understand how it works?
Just break it down into steps:

ABCDEFGHIJK
1Group 1Group 2Group 3Group 4Group 5Group 6Status 1Status 2Combined
2MIT Windows approvalBlahBlahBlahBlahBlahPublicPublicGTIS CMUK Windows ApprovalPublic
3BlahGTIS Hosting Platform TaurusMIT WindowsBlahBlahBlahPublicPrivateGTIS CMUK WindowsPublic
4BlahBlahGTIS Hosting Platform TaurusBlahBlahBlahPrivatePrivateUNIX-SUPPORT-FRPublic
5BlahBlahBlahBlahBlahBlahNoneNoneMIT WindowsPublic
6MIT UnixPublic
7MIT Windows ApprovalPublic
8H3, in stepsMIT Unix ApprovalPublic
9VLOOKUPGTIS Hosting Platform WindowsPublic
10#N/APrivatePublic#N/A#N/A#N/AGTIS Hosting Platform Taurus ApprovalPrivate
11GTIS Hosting Platform TaurusPrivate
12FilterGTIS Hosting Platform AtlasPrivate
13PrivatePublicGTIS Hosting Platform Atlas ApprovalPrivate
14
15Take first
16Private
17
Sheet1
Cell Formulas
RangeFormula
G2:G5G2=LET(p,IFERROR(VLOOKUP(Table2[@[Group 1]:[Group 6]],Combined,2,),""),IF(OR(p="Public"),"Public",IF(OR(p="Private"),"Private","None")))
H2:H5H2=LET(p,VLOOKUP(Table2[@[Group 1]:[Group 6]],Combined,2,),TAKE(FILTER(p,ISTEXT(p),"None"),,1))
A10:F10A10=VLOOKUP(A3:F3,Combined,2,)
A13:B13A13=FILTER(A10#,ISTEXT(A10#),"None")
A16A16=TAKE(A13#,,1)
Dynamic array formulas.
Named Ranges
NameRefers ToCells
Combined=Sheet1!$J$2:$K$13A10, G2:H5
 
Upvote 0
Thx Stephen.

One more question please.

If on one row there are groups belonging to both Private and Public:
-return each different value(Private and Public) in a different column
-the order of the returned values to be descending based on the number of iterations(if there are 3 Private groups and 2 Public groups, return in Private in column G and Public in column H)
-----> in below example, Groups 1, 2, 3 are PRIVATE (so 3 iterations) and Groups 4, 5 are PUBLIC --> so PRIVATE in column G and PUBLIC in column H

Group 1Group 2Group 3Group 4Group 5Group 6Group Category 1
column G
Group Category 2
column H
GTIS Hosting Platform Atlas ApprovalGTIS Hosting Platform AtlasGTIS Hosting Platform AtlasGTIS CMUK Windows ApprovalAPP-SRE-EIGTIS CMUK WindowsPRIVATEPUBLIC
 
Upvote 0
Perhaps like this?

I have assumed that if there are equal numbers of Public/Private the results should show Public and Private in that order.

ABCDEFGHIJK
1Group 1Group 2Group 3Group 4Group 5Group 6Status 1Status 2Combined
2MIT Windows approvalBlahBlahBlahBlahBlahPublic GTIS CMUK Windows ApprovalPublic
3BlahGTIS Hosting Platform TaurusMIT WindowsBlahBlahBlahPublicPrivateGTIS CMUK WindowsPublic
4BlahBlahGTIS Hosting Platform TaurusBlahBlahBlahPrivate UNIX-SUPPORT-FRPublic
5BlahBlahBlahBlahBlahBlah  MIT WindowsPublic
6BlahBlahMIT WindowsBlahBlahBlahPublic MIT UnixPublic
7GTIS Hosting Platform TaurusGTIS Hosting Platform TaurusMIT UnixMIT UnixPublicPrivateMIT Windows ApprovalPublic
8MIT Unix ApprovalPublic
9GTIS Hosting Platform WindowsPublic
10GTIS Hosting Platform Taurus ApprovalPrivate
11GTIS Hosting Platform TaurusPrivate
12GTIS Hosting Platform AtlasPrivate
13GTIS Hosting Platform Atlas ApprovalPrivate
14
Sheet1
Cell Formulas
RangeFormula
G2:G7G2=LET(p,{"Public";"Private"},n,BYROW(IFERROR(VLOOKUP(Table2[@[Group 1]:[Group 6]],Combined,2,),"None")=p,LAMBDA(r,SUM(--r))),IF(MAX(n)=0,"",INDEX(SORTBY(p,n,-1),1)))
H2:H7H2=LET(p,{"Public";"Private"},n,BYROW(IFERROR(VLOOKUP(Table2[@[Group 1]:[Group 6]],Combined,2,),"None")=p,LAMBDA(r,SUM(--r))),IF(MIN(n)=0,"",INDEX(SORTBY(p,n,-1),2)))
Named Ranges
NameRefers ToCells
Combined=Sheet2!$J$2:$K$13G2:H7
 
Upvote 0
Solution
Hi Stephen,

Sorry for the delayed response.

Formula does almost what I need

So, from your formula, if I remove INDEX, it will return #SPILL!
G2:G7G2=LET(p,{"Public";"Private"},n,BYROW(IFERROR(VLOOKUP(Table2[@[Group 1]:[Group 6]],Combined,2,),"None")=p,LAMBDA(r,SUM(--r))),IF(MAX(n)=0,"",INDEX(SORTBY(p,n,-1),1)))

If I am using A3:F3 instead of Table2[@[Group 1]:[Group 6]] I will get as per below

=LET(p,{"Public";"Private"},n,BYROW(IFERROR(VLOOKUP(A3:F3,COMBINED2,2),"None")=p,LAMBDA(r,SUM(--r))),IF(MAX(n)=0,"",SORTBY(p,n,1)))
Private
Public

What I would want is to have the spilled values go into separate columns, something like below

=TRANSPOSE(LET(p,{"Public";"Private"},n,BYROW(IFERROR(VLOOKUP(A3:F3,COMBINED2,2),"None")=p,LAMBDA(r,SUM(--r))),IF(MAX(n)=0,"",SORTBY(p,n,1))))
PrivatePublic

The issue is that, even with TRANSPOSE, if I am using Table2[@[Group 1]:[Group 6]] instead of A3:F3, it will still return #SPILL!
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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