# count the number of alphabets in a given cell

#### priyanka

##### New Member
Hello everyone,
Can anybody help me out- how to count the number of alphabets in a particular cell in excel.I am dealing with nucleotides. So, all cells have only alphabets A,C,G,T.
For eg: if the cell has agtcttgcaaatgcctaaaa
i want to know number of a's, t's, c's, d's in that particular cell...

Thank u so much in advance
Priyanka

### Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi Priyanka,

Would this work...

Excel Workbook
FG
2agtcttgcaaatgcctaaaa20
3
4a8
5c4
6g3
7t5
820
List

Hello,

Genetics work, by any chance?

Say that string was in the cell A1, to count the number of "a"'s, you could use this:
Code:
``=LEN(A1)-LEN(SUBSTITUTE(A1,"a",""))``

The easiest way is to create a User defined function. At the bottom of your sheet right click and highlight "View code".

Then at the top you will see a menu bar - click on Insert and then "Insert module".

and then copy and paste the code below.

then click File, close to Excel.

then if you want to count the number of "a"'s in aaag you type:-

=Count_Letters("aaaag","a")

Thanks

Kaps

Code:
``````Public Function Count_Letters(Text As String, Letter As String) As Long
Dim c As Long
Count_Letters = 0

For c = 1 To Len(Text)
If Ucase(Mid(Text, c, 1)) = Ucase(Letter) Then
Count_Letters = Count_Letters + 1

End If

Next c
End Function``````

Thank u so much.. All are working very well.. Thank all for an immediate response..

Replies
5
Views
210
Replies
10
Views
395
Replies
6
Views
368
Replies
0
Views
387
Replies
10
Views
871

1,206,755
Messages
6,074,754
Members
446,083
Latest member
kfunt

### 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.

### Which adblocker are you using?

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

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