Counting Asterisks

Stephen_IV

Well-known Member
Joined
Mar 17, 2003
Messages
1,180
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I am trying to count Asterisks in my data but to no avail.

<style type="text/css">
table.tableizer-table {
font-size: 12px;
border: 1px solid #CCC ;
font-family: Arial, Helvetica, sans-serif;
}
.tableizer-table td {
padding: 4px;
margin: 3px;
border: 1px solid #CCC ;
}
.tableizer-table th {
background-color: #104E8B ;
color: #FFF ;
font-weight: bold;
}
</style>
<table class="tableizer-table">
<thead><tr class="tableizer-firstrow"><th>DATA</th></tr></thead><tbody>
<tr><td>AAAA **</td></tr>
<tr><td>BBBB</td></tr>
<tr><td>CCCC ***</td></tr>
<tr><td>DDDD ****</td></tr>
<tr><td>EEEE</td></tr>
<tr><td>FFFF ***</td></tr>
<tr><td>GGGG ***</td></tr>
<tr><td>HHHH ***</td></tr>
<tr><td>IIII</td></tr>
<tr><td>JJJJ ***</td></tr>
<tr><td>KKKK ***</td></tr>
<tr><td>LLLL</td></tr>
<tr><td>MMMM</td></tr>
<tr><td>NNNN</td></tr>
<tr><td>OOOO ***</td></tr>
<tr><td>PPPP</td></tr>
<tr><td>QQQQ ***</td></tr>
<tr><td>RRRR ***</td></tr>
<tr><td>SSSS *</td></tr>
<tr><td>TTTT</td></tr>
<tr><td>UUUU</td></tr>
<tr><td>VVVV</td></tr>
<tr><td>WWWW ***</td></tr>
<tr><td>XXXX ***</td></tr>
<tr><td>YYYY ***</td></tr>
<tr><td>ZZZZ **</td></tr>
</tbody></table>

This is what I am looking for
<style type="text/css">
table.tableizer-table {
font-size: 12px;
border: 1px solid #CCC ;
font-family: Arial, Helvetica, sans-serif;
}
.tableizer-table td {
padding: 4px;
margin: 3px;
border: 1px solid #CCC ;
}
.tableizer-table th {
background-color: #104E8B ;
color: #FFF ;
font-weight: bold;
}
</style>
<table class="tableizer-table">
<thead><tr class="tableizer-firstrow"><th>Ast.</th><th>Count</th></tr></thead><tbody>
<tr><td>*</td><td>1</td></tr>
<tr><td>**</td><td>2</td></tr>
<tr><td>***</td><td>12</td></tr>
<tr><td>****</td><td>1</td></tr>
</tbody></table>
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Assuming
data from B2 to B27
G3 = *
G4 = **
etc ...
then J3=NbAst($B$2:$B$27,LEN(G3)) , copy and paste as needed

with next UDF



Code:
Option Explicit


Function NbAst(WkRg As Range, Sel As Integer) As Integer
Dim Rg  As Range
Dim Nb  As Integer
    For Each Rg In WkRg
        Nb = Len(Rg) - Len(Replace(Rg, "*", ""))
        If (Nb = Sel) Then NbAst = NbAst + 1
    Next Rg
End Function
 
Upvote 0
How about


Book1
ABCD
1DATAAst.Count
2AAAA ******1
3BBBB***12
4CCCC *****2
5DDDD *****1
6EEEE
7FFFF ***
8GGGG ***
9HHHH ***
10IIII
11JJJJ ***
12KKKK ***
13LLLL
14MMMM
15NNNN
16OOOO ***
17PPPP
18QQQQ ***
19RRRR ***
20SSSS *
21TTTT
22UUUU
23VVVV
24WWWW ***
25XXXX ***
26YYYY ***
27ZZZZ **
Sheet1
Cell Formulas
RangeFormula
D2=COUNTIF(A:A,"*"&SUBSTITUTE(C2,"*","~*"))-SUM(D$1:D1)
 
Upvote 0
Another option


Book1
ABEF
1DATAAst.Count
2AAAA ***1
3BBBB**2
4CCCC ******12
5DDDD ********1
6EEEE
7FFFF ***
8GGGG ***
9HHHH ***
10IIII
11JJJJ ***
12KKKK ***
13LLLL
14MMMM
15NNNN
16OOOO ***
17PPPP
18QQQQ ***
19RRRR ***
20SSSS *
21TTTT
22UUUU
23VVVV
24WWWW ***
25XXXX ***
26YYYY ***
27ZZZZ **
Sheet1
Cell Formulas
RangeFormula
F2=SUMPRODUCT(--(RIGHT($A$2:$A$27,LEN(E2)+1)=" "&E2))
 
Upvote 0
Assuming
data from B2 to B27
G3 = *
G4 = **
etc ...

Another one

J3=SUM(IF( LEN($B$2:$B$27)-LEN(SUBSTITUTE($B$2:$B$27,"*",""))=LEN(G3),1,0))
confirm using Control + Shift + enter
 
Upvote 0
Assuming
data from B2 to B27
G3 = *
G4 = **
etc ...

Another one more simple ( No Control + Shift + enter )

J3=SUMPRODUCT(--(LEN($B$2:$B$27)-LEN(SUBSTITUTE($B$2:$B$27,"*",""))=LEN(G3)))
 
Last edited:
Upvote 0
Thank you both very much!! I was scratching my head a little!!! But I appreciate all of your help and guidance!!!!
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
Please to help
Enjoy Excel
 
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