Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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
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
Converting numbers to words Pat Excel Discussion (Misc queries) 1 December 29th 08 09:58 PM
Converting Numbers to words Srinivasulu B New Users to Excel 7 December 3rd 07 10:23 PM
converting numbers to words alok Excel Discussion (Misc queries) 1 May 14th 07 09:03 AM
Converting words to numbers vstromer77 Excel Discussion (Misc queries) 3 February 6th 06 03:48 PM
Converting numbers into words? Dean Excel Discussion (Misc queries) 1 December 22nd 05 10:34 PM


All times are GMT +1. The time now is 06:03 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"