# Counting a character in MS-Excel (Mac)

Mark Yeager yeagerm at jeflin.tju.edu
Mon Aug 28 12:53:20 EST 1995

```In article <v01510100ac62011a3143@[143.48.11.21]>, lodhi at CSHL.ORG

> Does anyone know how to count a particular character ,e.g., 'A' or 'C' from
> an oligo sequence in an Excel cell?  I am trying to develop a sheet to
> calculate Tm, concentration , etc. of oligos that we use in our primer
> walking.  If someone already has anything like that for Mac, I 'll
> appreciate for the pointers.  Thanks in advance

I have exactly what you need. The function for counting characters is for
Excel 5, but you could adapt it for Excel 4 as a macro. The sheet also
calculates extinction coefficient, volumes of water and stock primer to
make up appropriate concentrations, and Tm.

If you have Excel 5, you can use the following Visual Basic function in
the sheet to count the numbers of each base. You do so by selecting the
menu item "Insert ... Macro ... Module"
----------

' Counts number of string character 'base' in string 'oligo'
' Usage example:    =numbases(B7,'t')
'           where 'B7' is an example cell with the oligo sequence
'           and 't' is the character to count
' M. Yeager, yeagerm at jeflin.tju.edu

Function NumBases(oligo, base)
oligo = LCase\$(oligo)
base = LCase\$(base)
sumbase = 0
For I = 1 To Len(oligo)
If Mid\$(oligo, I, 1) = base Then
sumbase = sumbase + 1
End If
Next I
NumBases = sumbase
End Function
--------------------

If you wish, I'll email you or anyone a binhexed copy of the entire sheet.

--
--  -.--
Mark Yeager ->   yeagerm at jeflin.tju.edu
Dept. Pathology and Cell Biology, Thomas Jefferson Univ., Phila., PA

```