Count A's

Count A's

Post by U3BlbmNlci » Sun, 20 Mar 2005 07:43:07

is there a VBA statement that can return the number of times the letter A
appears in a range named ("Letters"). this range contains only single letter
values, A, G, M, I, P, and R. i want to count how many A's there are in this
range. TIA.

Count A's

Post by 42N83 » Sun, 20 Mar 2005 07:51:25

In VBA, if in fact each cell in the range only contains a single letter, you
could do this:

Dim cell as range
Dim a as Long

For Each cell in Range("Letters").Cells
If cell.Value = "A" Then
a = a + 1
End If
Next cell


Count A's

Post by Bob Philli » Sun, 20 Mar 2005 08:08:25

cNum = Application.Countif(Range("Letters"),"A")



(remove nothere from the email address if mailing direct)


Count A's

Post by VCBLaXJ0bG » Sun, 20 Mar 2005 08:13:01

To count the cells in a range that have a specific letter (or any particular
value) then try the COUNTIF() function. Something like COUNTIF(A1:A10,"A")
will count the number of cells in the range from A1 to A10 that have a value
of "A".

If you want to count the number of times a specific character occurs in a
single cell try something like: LEN(A1)-LEN(SUBSTITUTE(A1,"a","")) which will
return the total number of times the letter "a" occurs in cell A1.

Hope that helps.