HOW DO YOU COUNT ALPHA CHARACTERS IN AN ALPHANUMERIC FIELD
On Wed, 29 Aug 2007 14:50:01 -0700, PVSPRO
wrote:
You could use this UDF:
================
Option Explicit
Function AlphaCount(str As String) As Long
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "[^A-Za-z]"
AlphaCount = Len(re.Replace(str, ""))
End Function
====================
You enter this in a regular module:
<alt-F11 opens the VBEditor
Ensure your project is highlighted in the project explorer window, then
Insert/Module and paste the code above into the window that opens.
You then enter a formula:
=AlphaCount(cell_ref) in some cell on your worksheet to get a count of the
"alpha" characters in cell_ref.
If you want to include other characters than A-Za-z, just add them at the end
of "pattern"
--ron
|