count the number of alphabets in a given cell

priyanka

New Member
Joined
Oct 9, 2008
Messages
29
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.
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",""))
 
Upvote 0
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
 
Upvote 0

Forum statistics

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