Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Ron - is there a decent resource where I could learn more about how to use
VBA regular expressions?? "Ron Rosenfeld" wrote: 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 |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
On Wed, 29 Aug 2007 22:56:00 -0700, JMB wrote:
Ron - is there a decent resource where I could learn more about how to use VBA regular expressions?? I've found these quite helpful as a beginning. http://support.microsoft.com/default...02&Product=vbb http://msdn2.microsoft.com/en-us/library/6wzad2b2.aspx http://www.regular-expressions.info/reference.html --ron |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks!!
"Ron Rosenfeld" wrote: On Wed, 29 Aug 2007 22:56:00 -0700, JMB wrote: Ron - is there a decent resource where I could learn more about how to use VBA regular expressions?? I've found these quite helpful as a beginning. http://support.microsoft.com/default...02&Product=vbb http://msdn2.microsoft.com/en-us/library/6wzad2b2.aspx http://www.regular-expressions.info/reference.html --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
format cell to place colon btw every 2 alphanumeric characters | Excel Worksheet Functions | |||
Merge an alpha field and a numeric field | Excel Discussion (Misc queries) | |||
Find largest alphanumeric value matching alpha criteria in databas | Excel Worksheet Functions | |||
Count unique alpha numeric "characters" in a common cell | Excel Worksheet Functions |