countifs help

Barto

Board Regular
Joined
Jul 30, 2013
Messages
78
Hi,

I'm trying to do a "countifs" formula that has to meet a few criteria and there is one criteria I'm not sure how to write (the other criteria are straight forward)

the criteria is if I find certain text in a cell but the text could be anywhere in the cell... at the start at the end in the middle..

For example if I'm looking for "VEA 01" how do I get it to count it if is appears somewhere in the cell

Example cell 1 = "VEA 05 VEA 03 VEA 01"
Example cell 2 = "VEA 01 VEA 06 VEA 04"
Example cell 3 = "VEA 05 VEA 01 VEA 04"
Example cell 4 = "VEA 05 VEA 01"
Example cell 5 = "VEA 01"

In all of the above examples VEA 01 has appeared somewhere in the cell so I want it counted..
 

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

FDibbins

Well-known Member
Joined
Feb 16, 2013
Messages
6,723
maybe include this in your main formula...
ISNUMBER(search("*VEA 01*",A1,1)
 

johnmpl

Board Regular
Joined
Jun 14, 2013
Messages
235
Hi!

If you have the data in A1:A5, you can use this formula:

=COUNTIF(A1:A5,"*VEA 01*")

Blessings!
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,279
Office Version
  1. 2013
Platform
  1. Windows
Try

<b>Excel 2010</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>A</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="color: #333333;;">VEA 05 VEA 03 VEA 01</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="color: #333333;;">Bob</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="color: #333333;;">VEA 05 VEA 03 VEA 03</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="color: #333333;;">bob</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="color: #333333;;">Bob</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="color: #333333;;">VEA 05 VEA 03 VEA 06</td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="color: #333333;;">VEA 05 VEA 03 VEA 07</td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="color: #333333;;">Bob</td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style="color: #333333;;">VEA 05 VEA 03 VEA 09</td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style="color: #333333;;">VEA 05 VEA 03 VEA 10</td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style="color: #333333;;">Bob</td></tr><tr ><td style="color: #161120;text-align: center;">12</td><td style="color: #333333;;">Bob</td></tr><tr ><td style="color: #161120;text-align: center;">13</td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">14</td><td style="text-align: right;;">6</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet2</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #BBB"><thead><tr style=" background-color: #DAE7F5;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">A14</th><td style="text-align:left">=COUNTIF(<font color="Blue">A1:A12,"*VEA 05*"</font>)</td></tr></tbody></table></td></tr></table><br />
 

Barto

Board Regular
Joined
Jul 30, 2013
Messages
78

ADVERTISEMENT

What if "VEA 05" was in a cell say g2? I tried =COUNTIF(A1:A12,"*"&g2&"*") but this only works if VEA 05 appears in the middle of the cell somewhere?


Try

Excel 2010
A
1VEA 05 VEA 03 VEA 01
2Bob
3VEA 05 VEA 03 VEA 03
4bob
5Bob
6VEA 05 VEA 03 VEA 06
7VEA 05 VEA 03 VEA 07
8Bob
9VEA 05 VEA 03 VEA 09
10VEA 05 VEA 03 VEA 10
11Bob
12Bob
13
146

<colgroup><col style="width: 25pxpx"><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
A14=COUNTIF(A1:A12,"*VEA 05*")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 

alansidman

Well-known Member
Joined
Feb 26, 2007
Messages
5,864
Office Version
  1. 2019
Platform
  1. Windows
Assume your data is in column A, and Column B is currently blank, then this VBA solution should work.

Code:
Option Explicit


Sub foo()
Dim lr As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
Dim i As Long
Dim tot As Long


For i = 1 To lr
If Range("A" & i) Like "*VEA 01*" Then
Range("B" & i) = 1
End If
Next i




tot = WorksheetFunction.Sum(Range("B1:B" & lr))
MsgBox ("Total VEA 01 =" & tot)


End Sub
 

Barto

Board Regular
Joined
Jul 30, 2013
Messages
78

ADVERTISEMENT

To put more context be the VEA outcomes column shows how it populates each cell

and the first and second columns show the various outcomes and what the counts should equal
OutcomeCount should equalVEA CALL OUTCOMES
VEA 01 - jump2VEA 01 - jump;VEA 04 -how to do itj;VEA 05 - over there;VEA 17 - check
VEA 02 - due cause4VEA 04A - now;VEA 08 - entry level
VEA 04 -how to do itj1VEA 02 - due cause
VEA 04A - now2VEA 02 - due cause
VEA 05 - over there;VEA 17 - check1VEA 29 - PV - Party Apps;VEA 33 - I/S & O/S General
VEA 08 - entry level1VEA 02 - due cause;VEA 04A - now
VEA 09 - Enrolment - Check1VEA 01 - jump;VEA 09 - Enrolment - Check
VEA 17 - check1VEA 02 - due cause
VEA 29 - PV - Party Apps1
VEA 33 - I/S & O/S General1

<colgroup><col><col><col></colgroup><tbody>
</tbody>
 

Barto

Board Regular
Joined
Jul 30, 2013
Messages
78
with corection
To put more context be the VEA outcomes column shows how it populates each cell

and the first and second columns show the various outcomes and what the counts should equal
Outcome
Count should equal
VEA CALL OUTCOMES
VEA 01 - jump
2
VEA 01 - jump;VEA 04 -how to do itj;VEA 05 - over there;VEA 17 - check
VEA 02 - due cause
4
VEA 04A - now;VEA 08 - entry level
VEA 04 -how to do itj
1
VEA 02 - due cause
VEA 04A - now
2
VEA 02 - due cause
VEA 05 - over there
1
VEA 29 - PV - Party Apps;VEA 33 - I/S & O/S General
VEA 08 - entry level
1
VEA 02 - due cause;VEA 04A - now
VEA 09 - Enrolment - Check
1
VEA 01 - jump;VEA 09 - Enrolment - Check
VEA 17 - check
1
VEA 02 - due cause
VEA 29 - PV - Party Apps
1
VEA 33 - I/S & O/S General
1

<TBODY>
</TBODY>
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,279
Office Version
  1. 2013
Platform
  1. Windows
Try
Code:
=COUNTIF(A1:A12,"*"&G2&"*")
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,279
Office Version
  1. 2013
Platform
  1. Windows
Try

<b>Excel 2010</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">Outcome</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">Count should equal</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA CALL OUTCOMES</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 01 - jump</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 01 - jump;VEA 04 -how to do itj;VEA 05 - over there;VEA 17 - check</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 02 - due cause</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">4</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 04A - now;VEA 08 - entry level</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 04 -how to do itj</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">1</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 02 - due cause</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 04A - now</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">2</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 02 - due cause</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 05 - over there</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">1</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 29 - PV - Party Apps;VEA 33 - I/S & O/S General</td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 08 - entry level</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">1</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 02 - due cause;VEA 04A - now</td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 09 - Enrolment - Check</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">1</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 01 - jump;VEA 09 - Enrolment - Check</td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 17 - check</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">1</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 02 - due cause</td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 29 - PV - Party Apps</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">1</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">VEA 33 - I/S & O/S General</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">1</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet3</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #BBB"><thead><tr style=" background-color: #DAE7F5;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">B2</th><td style="text-align:left">=COUNTIF(<font color="Blue">$E$2:$E$11,"*"&A2&"*"</font>)</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">B3</th><td style="text-align:left">=COUNTIF(<font color="Blue">$E$2:$E$11,"*"&A3&"*"</font>)</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">B4</th><td style="text-align:left">=COUNTIF(<font color="Blue">$E$2:$E$11,"*"&A4&"*"</font>)</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">B5</th><td style="text-align:left">=COUNTIF(<font color="Blue">$E$2:$E$11,"*"&A5&"*"</font>)</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">B6</th><td style="text-align:left">=COUNTIF(<font color="Blue">$E$2:$E$11,"*"&A6&"*"</font>)</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">B7</th><td style="text-align:left">=COUNTIF(<font color="Blue">$E$2:$E$11,"*"&A7&"*"</font>)</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">B8</th><td style="text-align:left">=COUNTIF(<font color="Blue">$E$2:$E$11,"*"&A8&"*"</font>)</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">B9</th><td style="text-align:left">=COUNTIF(<font color="Blue">$E$2:$E$11,"*"&A9&"*"</font>)</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">B10</th><td style="text-align:left">=COUNTIF(<font color="Blue">$E$2:$E$11,"*"&A10&"*"</font>)</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">B11</th><td style="text-align:left">=COUNTIF(<font color="Blue">$E$2:$E$11,"*"&A11&"*"</font>)</td></tr></tbody></table></td></tr></table><br />
 

Watch MrExcel Video

Forum statistics

Threads
1,109,489
Messages
5,529,168
Members
409,853
Latest member
Amy Gassett
Top