Counting $ Signs

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a column that contains text and within that text appears "$". I need in cell B1 to count how many times there is a $ in A1 and then fill down Column B. I tried =countif(A1:A1, "$") but it doesn't seem to work. I then want to use this count as a criteria to apply functions to certain cells.
Thanks.
 
Hi

If you want the formula to count the $ wherever it appears, one option is to
use the * wildcard:
=COUNTIF(A1:A1,"*$*")

--
Andy.


teddyb777 said:
I have a column that contains text and within that text appears "$". I
need in cell B1 to count how many times there is a $ in A1 and then fill
down Column B. I tried =countif(A1:A1, "$") but it doesn't seem to work. I
then want to use this count as a criteria to apply functions to certain
cells.
 
Hi,

Try this. Assuming your text is in cell B4, array enter (Ctrl+Shift+Enter) the following formula in cell D4

SUM(IF(MID($B$4,ROW(1:20),1)="$",1,0))

I have assumed that length of the string is 20, you may adjust the number in the formula, there is no restriction

Regards,
 
Ashish Mathur said:
Try this. . . .

SUM(IF(MID($B$4,ROW(1:20),1)="$",1,0))

I have assumed that length of the string is 20, you may adjust
the number in the formula, there is no restriction

The more common answer in this newsgroup is

=LEN($B$4)-LEN(SUBSTITUTE($B$4,"$",""))

which doesn't require array entry, doesn't require guessing the length of
B4, and works with text of any permissible length.
 
Back
Top