LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pete_UK
 
Posts: n/a
Default change letter to number add number

You've changed the rules a bit from the first posting, but here is a
UDF to do what you asked for in your later post:

Function txt_num(my_name As String)
' Pete Ashurst, 29/03/2006
'
Dim my_num As Long
Dim i As Long
Dim char As Long
txt_num = 0
If Len(my_name) = 0 Then Exit Function
my_name = LCase(my_name)
my_num = 0
For i = 1 To Len(my_name)
char = Asc(Mid(my_name, i, 1))
If char < 97 Or char 122 Then Exit Function
my_num = my_num + ((char - 97) Mod 9 + 1)
Next i
my_num = Int(my_num / 1000) + Int(my_num / 100) _
+ Int(my_num / 10) + my_num Mod 10
txt_num = Int(my_num / 10) + my_num Mod 10
End Function

Type your name into A1 and use this formula in B1:

=txt_num(A1)

The formula can be copied down for as many names as you have in column
A. The UDF will return 0 if you have any characters other than A to Z
or a to z or if there is nothing in the corresponding cell of column A.

Hope this is what you wanted.

Pete

 
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
Change cell color if it is the lowest number of a group? Anthony Excel Discussion (Misc queries) 3 October 20th 05 02:05 AM
Change number when you open the excel template mowen Excel Discussion (Misc queries) 3 October 18th 05 08:05 PM
adding a number to every change in value Breinn Excel Discussion (Misc queries) 3 October 12th 05 06:09 PM
Count number of cells that contain a certain letter - Case Sensitive elite Excel Discussion (Misc queries) 4 September 20th 05 01:41 PM
How do I change the invoice number assigned in Invoice template... akress Excel Discussion (Misc queries) 1 February 28th 05 06:36 PM


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

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

About Us

"It's about Microsoft Excel"