![]() |
Count A's
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
"Spencer Hutton" wrote in message ... 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. 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
cNum = Application.Countif(Range("Letters"),"A") -- HTH RP (remove nothere from the email address if mailing direct) "Spencer Hutton" wrote in message ... 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
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. TK "Spencer Hutton" wrote: 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. |
All times are GMT +1. The time now is 02:51 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com