Searching for 2 different values in the same cell in a different tab

andrebooyzen

New Member
Joined
May 30, 2023
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Hi All

I need some help please. I am using the following formula to search and count the occurrences of 2 different values occurring together in the same cell in a separate tab. I am searching a range of cells in the tab and the matches may occur more than once in the range. In this case I am just testing the formula by using AAA and JJJ to search for. Excel keeps saying there is an error in the formula. Any help would be appreciated. Thanks :)

=COUNT(IF(OR(ISNUMBER(SEARCH("AAA",'15Apr24'!$J$3:$N$23)),ISNUMBER(SEARCH("JJJ",'15Apr24'!$J$3:$N$23)),1,"")))
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Thanks for the XL2BB sample data. Try
Excel Formula:
=LET(r,'15Apr24'!$J$3:$N$23,COUNTIFS(r,"*AAA*",r,"*JJJ*"))
 
Upvote 1
The first search always appears first in the cell and the 2nd one always second (i.e. AAA is always first and JJJ second). They will never be swapped around.
In that case try this. Remove all the formulas from B11:Q130 and place the formula shown below in B111. No need to copy it anywhere.


24 04 10_1.xlsm
ABCDEFGHIJKLMNOPQ
1Change dates when creating new weekAshmore
2--->>>Monday 15Apr24Tuesday 16Apr24Wednesday 17Apr24Thursday 18Apr24Friday 19Apr24
308:0008:00-09:40 Andre B Ebony B
408:3008:30-10:10 Andre B Mika Y110
509:0009:00-10:40 Colin B Mika Y11009:00-10:40 Adam L Jordyn L09:00-11:20 Martin A Mika Y
609:30110100100
710:0010:00-11:40 Mal A Heldy S
810:3010010:50-12:20 Adam L Joshua L
911:0011:00-12:40 Colin B Heldy S11:00-12:40 Paul H Jordyn L10011:00-12:40 Ashley C Alexander B
1011:30100100100
1112:0012:00-13:40 Garry Joshua L
1212:30100
1313:0013:00-14:20 Alex V Pamela A13:00-14:40 Rod M Isabella L13:00-14:40 Rod M Pamela A
1413:30100100100
1514:0014:00-15:40 Paul H Isabella L
1614:30100
1715:0015:00-16:40 Mal A Victoria D15:00-16:40 Pam M Ebony B15:00-16:40 Garry Ebony B15:00-16:40 Steve M Saleha I
1815:30100100100100
1916:00
2016:30
2117:0017:00-18:40 Jan N Farishta J17:00-18:40 Jan N Farishta J17:00-18:40 Callen P Mia A17:00-18:40 Callen P Mia A
2217:30110110110111
2318:00
24
25
108
109
110M/PAlexander BBrenden HEbony BFarishta JHeldy SIsabella LJordyn LJoshua LMelessa SMia AMika YPamela ASaleha IVictoria DZoe MNO P
111Adam L0000001100000000
112Alex V0000000000010000
113Andre B0010000000100000
114Ashley C1000000000000000
115Bruce S0000000000000000
116Callen P0000000002000000
117Chris R0000000000000000
118Colin B0000100000100000
119Garry0010000100000000
120Helen B0000000000000000
121Jan N0002000000000000
122Mal A0000100000000100
123Martin A0000000000100000
124Noel K0000000000000000
125Pam M0010000000000000
126Paul H0000011000000000
127Rod M0000010000010000
128Rod S0000000000000000
129Steve M0000000000001000
130NO M0000000000000000
15Apr24
Cell Formulas
RangeFormula
B111:Q130B111=COUNTIF(B3:F23,"*" &A111:A130&"*"&B110:Q110&"*")
Dynamic array formulas.
 
Upvote 1
Solution
Using your test values of "AAA" and "JJJ" could make up a set of dummy data for J3:N23 showing the sort of variety that might be encountered and post that with XL2BB and tell us what the expected count result should be?

(If you have trouble with XL2BB review the "XL2BB Icons greyed out" link in the 'Known XL2BB issues' section near the top of theXL2BB Instructions page linked above.)
 
Upvote 0
Here is some dummy data for the problem above

1712715353298.png
 
Upvote 0
BTC Running Sheet.xlsx.xlsb
ABCDEFGHIJKLMN
1Change dates when creating new weekAshmoreGold Coast
2--->>>Monday 15Apr24Tuesday 16Apr24Wednesday 17Apr24Thursday 18Apr24Friday 19Apr24Monday 15Apr24Tuesday 16Apr24Wednesday 17Apr24Thursday 18Apr24Friday 19Apr24
308:0008:00-09:40 Andre B Ebony B
408:3008:30-10:10 Andre B Mika Y110
509:0009:00-10:40 Colin B Mika Y11009:00-10:40 Adam L Jordyn L09:00-11:20 Martin A Mika Y09:00-10:40 Rod S Joslyn B09:00-10:40 Glenn B Nicolas B09:00-10:40 Franz H Nicolas B09:00-10:40 Dom T Joslyn B09:00-10:20 Rod S Izack M
609:30110100100100100100100101
710:0010:00-11:40 Mal A Heldy S
810:3010010:50-12:20 Adam L Joshua L10:50-12:20 Franz H Ayani D
911:0011:00-12:40 Colin B Heldy S11:00-12:40 Paul H Jordyn L10011:00-12:40 Ashley C Alexander B11:00-12:40 Rod S Nicolas B11:00-12:40 Glenn B Izack M10011:00-12:40 Andre B Izack M11:00-12:40 JJJ AAA
1011:3010010010010010011011:00-12:40 JJJ AAA
1112:0012:00-13:40 Garry Joshua L11:00-12:40 JJJ AAA
1212:3010012:30-14:10 Paula W Blake C
1313:0013:00-14:20 Alex V Pamela A13:00-14:40 Rod M Isabella L13:00-14:40 Rod M Pamela A13:00-15:00 Noel K Ayani D13:00-14:40 Andre B Emma C10013:00-14:40 Paula W Jennifer C13:00-14:40 Noel K Sophie B
1413:30100100100100100100100
1514:0014:00-15:40 Paul H Isabella L
1614:3010014:30-16:00 Mike J Sophie B14:45-16:30 Noel K Joslyn B
1715:0015:00-16:40 Mal A Victoria D15:00-16:40 Pam M Ebony B15:00-16:40 Garry Ebony B15:00-16:40 Steve M Saleha I15:00-16:40 Noel K Ella M100110
1815:30100100100100110
1916:0016:00-17:20 Janine T Ayani D
2016:30100
2117:0017:00-18:40 Jan N Farishta J17:00-18:40 Jan N Farishta J17:00-18:40 Callen P Mia A
2217:30110110110
2318:00
15Apr24
 
Upvote 0
Using your test values of "AAA" and "JJJ" could make up a set of dummy data for J3:N23 showing the sort of variety that might be encountered and post that with XL2BB and tell us what the expected count result should be?

(If you have trouble with XL2BB review the "XL2BB Icons greyed out" link in the 'Known XL2BB issues' section near the top of theXL2BB Instructions page linked above.)
Thanks Peter. See post #4 below.
 
Upvote 0
You had some mismatched brackets in your formula. Try:
Excel Formula:
=COUNT(IF(OR(ISNUMBER(SEARCH("AAA",'15Apr24'!$J$3:$N$23)),ISNUMBER(SEARCH("JJJ",'15Apr24'!$J$3:$N$23))),1,""))

but as it stands this formula will only ever return 1, so the COUNT is redundant and this will work equally well:
Excel Formula:
=IF(OR(ISNUMBER(SEARCH("AAA",'15Apr24'!$J$3:$N$23)),ISNUMBER(SEARCH("JJJ",'15Apr24'!$J$3:$N$23))),1,"")

Are you trying to count the occurrences of AAA and JJJ? Is the expected result from your data 3?
 
Upvote 0
You had some mismatched brackets in your formula. Try:
Excel Formula:
=COUNT(IF(OR(ISNUMBER(SEARCH("AAA",'15Apr24'!$J$3:$N$23)),ISNUMBER(SEARCH("JJJ",'15Apr24'!$J$3:$N$23))),1,""))

but as it stands this formula will only ever return 1, so the COUNT is redundant and this will work equally well:
Excel Formula:
=IF(OR(ISNUMBER(SEARCH("AAA",'15Apr24'!$J$3:$N$23)),ISNUMBER(SEARCH("JJJ",'15Apr24'!$J$3:$N$23))),1,"")

Are you trying to count the occurrences of AAA and JJJ? Is the expected result from your data 3?
Yes 3 is the correct return value. Thanks a lot :)
 
Upvote 0

Forum statistics

Threads
1,215,981
Messages
6,128,094
Members
449,419
Latest member
mammothzaa

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