Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Converting words to numbers
I had a teacher ask me if I could write a program that would convert words
to numerical equivalents. It's been a long time since I have done programming so I am asking for help. She is going to tell the kids they need to come up with a word that equal (lets say) 30. We always assume that a=1 b=2 c=3 d=4 etc. Can anyone help me? I managed to get the word that was entered and the length of the word. I think the next think I have to do is convert the word into an array and then convert each letter into a number. The place I am stuck is converting the word into an array that I can work with. Thnaks in advance for any help! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Converting words to numbers
I have made this macro for you...it is assuming that people put the
word in Range A1, but if you need it to be more versatile let me know. Sub letterizer() worder = Range("A1").Value intcounter = 1 Do Until worder = "" temp = Left(worder, 1) If Asc(worder) = 97 Then letterval = Asc(worder) - 96 Else letterval = Asc(worder) - 64 End If Cells(intcounter, 2).Value = letterval worder = Right(worder, Len(worder) - 1) intcounter = intcounter + 1 Loop End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Converting words to numbers
Here is a function that you can call from the worksheet
Function WordValue(rng) Dim sWord As String Dim i As Long Dim cWord As Long Dim temp If TypeName(rng) = "Range" Then sWord = rng.Value Else sWord = rng End If For i = 1 To Len(sWord) temp = Asc(UCase(Mid(sWord, i, 1))) - 64 cWord = cWord + temp Next i WordValue = cWord End Function Use like =WordValue(A1) or =WordValue("Hello") -- HTH RP (remove nothere from the email address if mailing direct) "Chip" wrote in message oups.com... I have made this macro for you...it is assuming that people put the word in Range A1, but if you need it to be more versatile let me know. Sub letterizer() worder = Range("A1").Value intcounter = 1 Do Until worder = "" temp = Left(worder, 1) If Asc(worder) = 97 Then letterval = Asc(worder) - 96 Else letterval = Asc(worder) - 64 End If Cells(intcounter, 2).Value = letterval worder = Right(worder, Len(worder) - 1) intcounter = intcounter + 1 Loop End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Converting words to numbers
You can do it with a formula. Assuming the word is in A1, then use
=SUMPRODUCT(CODE(UPPER(MID(SUBSTITUTE(A1,";",""),R OW(INDIRECT("1:"&LEN(SUBST ITUTE(A1,";","")))),1)))-64) -- HTH RP (remove nothere from the email address if mailing direct) "Bill Gowan" <gowan@frontiernedotnet wrote in message ... I had a teacher ask me if I could write a program that would convert words to numerical equivalents. It's been a long time since I have done programming so I am asking for help. She is going to tell the kids they need to come up with a word that equal (lets say) 30. We always assume that a=1 b=2 c=3 d=4 etc. Can anyone help me? I managed to get the word that was entered and the length of the word. I think the next think I have to do is convert the word into an array and then convert each letter into a number. The place I am stuck is converting the word into an array that I can work with. Thnaks in advance for any help! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Converting words to numbers - Thanks!!
Thanks for the help! This was exactly what I was looking for.
"Bill Gowan" <gowan@frontiernedotnet wrote in message ... I had a teacher ask me if I could write a program that would convert words to numerical equivalents. It's been a long time since I have done programming so I am asking for help. She is going to tell the kids they need to come up with a word that equal (lets say) 30. We always assume that a=1 b=2 c=3 d=4 etc. Can anyone help me? I managed to get the word that was entered and the length of the word. I think the next think I have to do is convert the word into an array and then convert each letter into a number. The place I am stuck is converting the word into an array that I can work with. Thnaks in advance for any help! |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Converting words to numbers - Thanks!!
Which one was?
-- HTH RP (remove nothere from the email address if mailing direct) "Bill Gowan" <gowan@frontiernedotnet wrote in message ... Thanks for the help! This was exactly what I was looking for. "Bill Gowan" <gowan@frontiernedotnet wrote in message ... I had a teacher ask me if I could write a program that would convert words to numerical equivalents. It's been a long time since I have done programming so I am asking for help. She is going to tell the kids they need to come up with a word that equal (lets say) 30. We always assume that a=1 b=2 c=3 d=4 etc. Can anyone help me? I managed to get the word that was entered and the length of the word. I think the next think I have to do is convert the word into an array and then convert each letter into a number. The place I am stuck is converting the word into an array that I can work with. Thnaks in advance for any help! |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Converting words to numbers - Thanks!!
Actually I am using both for now and I will let the teacher pick the way she
prefers. "Bob Phillips" wrote in message ... Which one was? -- HTH RP (remove nothere from the email address if mailing direct) "Bill Gowan" <gowan@frontiernedotnet wrote in message ... Thanks for the help! This was exactly what I was looking for. "Bill Gowan" <gowan@frontiernedotnet wrote in message ... I had a teacher ask me if I could write a program that would convert words to numerical equivalents. It's been a long time since I have done programming so I am asking for help. She is going to tell the kids they need to come up with a word that equal (lets say) 30. We always assume that a=1 b=2 c=3 d=4 etc. Can anyone help me? I managed to get the word that was entered and the length of the word. I think the next think I have to do is convert the word into an array and then convert each letter into a number. The place I am stuck is converting the word into an array that I can work with. Thnaks in advance for any help! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Converting numbers to words | Excel Discussion (Misc queries) | |||
Converting Numbers to words | New Users to Excel | |||
converting numbers to words | Excel Discussion (Misc queries) | |||
Converting words to numbers | Excel Discussion (Misc queries) | |||
Converting numbers into words? | Excel Discussion (Misc queries) |