Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default HOW DO YOU COUNT ALPHA CHARACTERS IN AN ALPHANUMERIC FIELD


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.misc
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default HOW DO YOU COUNT ALPHA CHARACTERS IN AN ALPHANUMERIC FIELD

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default HOW DO YOU COUNT ALPHA CHARACTERS IN AN ALPHANUMERIC FIELD

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   Report Post  
Posted to microsoft.public.excel.misc
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default HOW DO YOU COUNT ALPHA CHARACTERS IN AN ALPHANUMERIC FIELD

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
format cell to place colon btw every 2 alphanumeric characters hogsy Excel Worksheet Functions 0 August 17th 06 03:30 PM
Merge an alpha field and a numeric field grams Excel Discussion (Misc queries) 3 August 29th 05 11:33 PM
Find largest alphanumeric value matching alpha criteria in databas Alison Excel Worksheet Functions 7 August 4th 05 06:59 PM
Count unique alpha numeric "characters" in a common cell WIM4246 Excel Worksheet Functions 4 December 11th 04 02:27 AM


All times are GMT +1. The time now is 06:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"