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

Hello,

I need help writing a macro that will change letters to numbers and add
the numbers for a total.
Using the alphbet with special values for each letter.
Example:

CELL A1 is rudy
r = 1
u = 2
d = 4
y = 3

total = 10

So if cell A1 = Rudy then B1 will show 10

if A2 = Rud then B2 will show 9

if A3 = B L A N K then B3 will show nothing

Thanks in advance,
Bill

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
 
Posts: n/a
Default change letter to number add number

a-i = 1-9 ==== j-r = 1-9 ====== s-z = 1-8

a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8, i=9,
j=1, k=2, etc..................

objective is to write a name like ANGEL then formula
ANGEL = 15753 = sum it to 1+5+7+5+3=21=3

Result is ANGEL(Cell A1) = 3(cell B1)
user types ANGEL in column A gets result in column B

Thanks

  #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

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
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 11:01 PM.

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"