Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default Converting number to text

Hello all

I have combination of numbers and text in several cells for ex. "325 Bob".
how can I convert the numbers to text. Output ex. "three two five Bob" in
the cell.

thx.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200707/1

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 13
Default Converting number to text

This user-defined function should do the trick. Press F11 to open VB, then
click on the menu Insert Module, then copy the following code to the right
pane.

Function SpellNumbers(s)

Dim i As Long
Dim sOutput As String


sOutput = ""
For i = 1 To Len(s)
Select Case Mid(s, i, 1)
Case 0
sOutput = sOutput & "zero "
Case 1
sOutput = sOutput & "one "
Case 2
sOutput = sOutput & "two "
Case 3
sOutput = sOutput & "three "
Case 4
sOutput = sOutput & "four "
Case 5
sOutput = sOutput & "five "
Case 6
sOutput = sOutput & "six "
Case 7
sOutput = sOutput & "seven "
Case 8
sOutput = sOutput & "eight "
Case 9
sOutput = sOutput & "nine "
Case Else
sOutput = sOutput & Mid(s, i, 1)
End Select
Next i

SpellNumbers = sOutput

End Function


In your spreadsheet, you can use =SpellNumbers("325 Bob") or =SpellNumbers(B3)


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default Converting number to text

Thank you so much. It works great.

squenson wrote:
This user-defined function should do the trick. Press F11 to open VB, then
click on the menu Insert Module, then copy the following code to the right
pane.

Function SpellNumbers(s)

Dim i As Long
Dim sOutput As String


sOutput = ""
For i = 1 To Len(s)
Select Case Mid(s, i, 1)
Case 0
sOutput = sOutput & "zero "
Case 1
sOutput = sOutput & "one "
Case 2
sOutput = sOutput & "two "
Case 3
sOutput = sOutput & "three "
Case 4
sOutput = sOutput & "four "
Case 5
sOutput = sOutput & "five "
Case 6
sOutput = sOutput & "six "
Case 7
sOutput = sOutput & "seven "
Case 8
sOutput = sOutput & "eight "
Case 9
sOutput = sOutput & "nine "
Case Else
sOutput = sOutput & Mid(s, i, 1)
End Select
Next i

SpellNumbers = sOutput

End Function

In your spreadsheet, you can use =SpellNumbers("325 Bob") or =SpellNumbers(B3)


--
Message posted via http://www.officekb.com

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 text to number Julio Excel Worksheet Functions 1 December 8th 06 06:47 PM
Converting number to text rslater44 Excel Discussion (Misc queries) 1 March 2nd 06 09:56 PM
converting text to number Anat Excel Discussion (Misc queries) 5 February 23rd 06 08:25 PM
CONVERTING NUMBER TO TEXT RAJEEV CHADHA Excel Worksheet Functions 3 April 22nd 05 02:05 PM
Converting text to a number Helen Black Excel Worksheet Functions 0 January 19th 05 01:33 PM


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