Anyone got an elegant and efficient way of making xl cause a positive integral number in cell, say a1, provoke the appearance of english words describing that number in cell, say a2?
Example: 3409 —————– THREE THOUSAND FOUR HUNDRED AND NINE
up to 4 digits only will do for present purpose.
Have been @#$!% around with a lookup table (and loads of IFs) but not simple and certainly not elegant.
Thanks
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
numbers-to-text (xl 97 sr2)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » numbers-to-text (xl 97 sr2)
- This topic has 9 replies, 4 voices, and was last updated 22 years, 9 months ago.
AuthorTopicWSitshimagain
AskWoody LoungerSeptember 9, 2002 at 3:02 pm #376212Viewing 3 reply threadsAuthorReplies-
WSsdckapr
AskWoody LoungerSeptember 9, 2002 at 3:55 pm #615253Here is a function to have a number change to text if A1 “100”, in B1 you could enter “=NumbertoWords(a1)” and B1 would display “One Hundred”. It does not affect the number.
I also have a subroutine which will convert ALL the numbers in a selected range of cells to the text. This will “destroy” the values in the cells. If desired, copy the range to a place before replacing or change to code to copy the text one column over.
it is valid for Integers from 0 to 999,999.There are also several subroutines that the 2 programs call. I got these from Allen Wyatt’s Excel Tips, though I have seen variations at many places.
Hope it comes in handy,
SteveFunction NumberToWords(rngSrc As Range) Dim lMax As Long Dim bNCFlag As Boolean Dim lNumber As Long, sWords As String bNCFlag = False vCVal = rngSrc.Value NumberToWords = "" If IsNumeric(vCVal) Then If vCVal CLng(vCVal) Then bNCFlag = True Else lNumber = CLng(vCVal) Select Case lNumber Case 0 NumberToWords = "Zero" Case 1 To 999999 NumberToWords = SetThousands(lNumber) Case Else bNCFlag = True End Select End If Else bNCFlag = True End If If NumberToWords = "" Then NumberToWords = CVErr(xlErrNull) End If If bNCFlag Then NumberToWords = CVErr(xlErrNA) End If End Function Sub RangeNumberToWords() Dim rngSrc As Range Dim lMax As Long Dim bNCFlag As Boolean Dim sTitle As String, sMsg As String Dim vCVal As Variant Dim lNumber As Long, sWords As String Set rngSrc = ActiveSheet.Range(ActiveWindow.Selection.Address) lMax = rngSrc.Cells.Count bNCFlag = False For lCtr = 1 To lMax vCVal = rngSrc.Cells(lCtr).Value sWords = "" If IsNumeric(vCVal) Then If vCVal CLng(vCVal) Then bNCFlag = True Else lNumber = CLng(vCVal) Select Case lNumber Case 0 sWords = "Zero" Case 1 To 999999 sWords = SetThousands(lNumber) Case Else bNCFlag = True End Select End If Else bNCFlag = True End If If sWords > "" Then rngSrc.Cells(lCtr) = sWords End If Next lCtr If bNCFlag Then sTitle = "lNumberToWords Macro" sMsg = "Not all cells converted. May not be whole number or maybe too large." MsgBox sMsg, vbExclamation, sTitle End If End Sub Private Function SetOnes(ByVal lNumber As Integer) As String Dim OnesArray(9) As String OnesArray(1) = "One" OnesArray(2) = "Two" OnesArray(3) = "Three" OnesArray(4) = "Four" OnesArray(5) = "Five" OnesArray(6) = "Six" OnesArray(7) = "Seven" OnesArray(8) = "Eight" OnesArray(9) = "Nine" SetOnes = OnesArray(lNumber) End Function Private Function SetTens(ByVal lNumber As Integer) As String Dim TensArray(9) As String TensArray(1) = "Ten" TensArray(2) = "Twenty" TensArray(3) = "Thirty" TensArray(4) = "Fourty" TensArray(5) = "Fifty" TensArray(6) = "Sixty" TensArray(7) = "Seventy" TensArray(8) = "Eighty" TensArray(9) = "Ninety" Dim TeensArray(9) As String TeensArray(1) = "Eleven" TeensArray(2) = "Twelve" TeensArray(3) = "Thirteen" TeensArray(4) = "Fourteen" TeensArray(5) = "Fifteen" TeensArray(6) = "Sixteen" TeensArray(7) = "Seventeen" TeensArray(8) = "Eighteen" TeensArray(9) = "Nineteen" Dim iTemp1 As Integer Dim iTemp2 As Integer Dim sTemp As String iTemp1 = Int(lNumber / 10) iTemp2 = lNumber Mod 10 sTemp = TensArray(iTemp1) If (iTemp1 = 1 And iTemp2 > 0) Then sTemp = TeensArray(iTemp2) Else If (iTemp1 > 1 And iTemp2 > 0) Then sTemp = sTemp + " " + SetOnes(iTemp2) End If End If SetTens = sTemp End Function Private Function SetHundreds(ByVal lNumber As Integer) As String Dim iTemp1 As Integer Dim iTemp2 As Integer Dim sTemp As String iTemp1 = Int(lNumber / 100) iTemp2 = lNumber Mod 100 If iTemp1 > 0 Then sTemp = SetOnes(iTemp1) + " Hundred" If iTemp2 > 0 Then If sTemp > "" Then sTemp = sTemp + " " If iTemp2 9 Then sTemp = sTemp + SetTens(iTemp2) End If SetHundreds = sTemp End Function Private Function SetThousands(ByVal lNumber As Long) As String Dim iTemp1 As Integer Dim iTemp2 As Integer Dim sTemp As String iTemp1 = Int(lNumber / 1000) iTemp2 = lNumber Mod 1000 If iTemp1 > 0 Then sTemp = SetHundreds(iTemp1) + " Thousand" If iTemp2 > 0 Then If sTemp > "" Then sTemp = sTemp + " " sTemp = sTemp + SetHundreds(iTemp2) End If SetThousands = sTemp End Function
-
WSitshimagain
AskWoody Lounger -
WSAladin Akyurek
AskWoody LoungerSeptember 9, 2002 at 6:03 pm #615279NUMTEXT
which is part of MOREFUNC.XLL (a fast add-in, downloadable from: http://longre.free.fr/english/index.html)
will do what you want.
-
WSitshimagain
AskWoody LoungerSeptember 11, 2002 at 2:26 pm #615925Thanks v much, all 3. Have run with the MOREFUNC method, which works a treat.
But if and only if the machine reading the file with the =numtext function in it is fitted up with the add-in.
Daft question – is there any way of ’embedding’ the function in the file, like a typeface can be embedded in a Word doc?
I suspect ‘no’ but the world is full of surprises, some of them nice. -
WSsdckapr
AskWoody Lounger -
WSitshimagain
AskWoody LoungerSeptember 11, 2002 at 2:37 pm #615933Ok, Steve, so it’s possible.
But to me the only ‘function command’ I know is to type
=numtext(cellref) into a cell (actually, = if(cellref=””,””,numtext(cellref)) and set up the numtext bit to show 2 dec places and include the word ‘pound’) which it plurals for me.
I know where the VIsual Basic editor lives, but beyond that, almost zilch.
How do I extract the code from the function?
Thanks!
John -
H. Legare Coleman
AskWoody PlusSeptember 11, 2002 at 3:01 pm #615940Since you use the MoreFunc.XLL which is a addin, the VBA code may not be available to you. If it is, it would be in the file that you downloaded to get the addin.
My post and at least one other contains the VBA code that would need to be copied and pasted into a VBA module in your workbook.
-
-
-
-
WSAladin Akyurek
AskWoody Lounger
-
H. Legare Coleman
AskWoody PlusSeptember 9, 2002 at 7:29 pm #615275Here is what I use, it works for up to Sextllions. It will also give you something like Three Hundred Thirty Dollars and Sixty Seven Cents if you pass it the optional second and third parameters. like this:
=NumberToText(330.67,"Dollars","Cents")
Function NumberToText(Num As Variant, Optional vCurName As Variant, Optional vCent As Variant) As Variant Dim TMBT As Variant Dim sNum As String, sDec As String, sHun As String, IC As Integer Dim Result As String, sCurName As String, sCent As String If Application.IsNumber(Num) = False Then NumberToText = CVErr(xlValue) Exit Function End If If IsMissing(vCurName) Then sCurName = "" Else sCurName = Trim(CStr(vCurName)) End If If IsMissing(vCent) Then sCent = "" Else sCent = Trim(CStr(vCent)) End If TMBT = Array("", "Thousand", "Million", "Billion", "Trillion", "Quadrillion", "Quintillion", "Sextillion") If IsMissing(sCent) Or IsNull(sCent) Then sNum = Format(Application.Round(Num, 0), "0") Else sNum = Format(Application.Round(Num, 2), "0.00") sDec = Right(sNum, 2) sNum = Left(sNum, Len(sNum) - 3) If CInt(sDec) 0 Then sDec = "and " & Trim(HundredsToText(CVar(sDec)) & " " & sCent) Else sDec = "" End If End If IC = 0 While Len(sNum) > 0 sHun = Right(sNum, 3) sNum = Left(sNum, Application.Max(Len(sNum) - 3, 0)) If CInt(sHun) 0 Then Result = Trim(Trim(HundredsToText(CVar(sHun)) & " " & TMBT(IC)) & " " & Result) End If IC = IC + 1 Wend Result = Trim(Result & " " & sCurName) Result = Trim(Result & " " & sDec) NumberToText = Result End Function Function HundredsToText(Num As Integer) As String Dim Units As Variant, Teens As Variant, Tens As Variant Dim I As Integer, IUnit As Integer, ITen As Integer, IHundred As Integer Dim Result As String Units = Array("", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine") Teens = Array("Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", _ "Eighteen", "Nineteen") Tens = Array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety") Result = "" IUnit = Num Mod 10 I = Int(Num / 10) ITen = I Mod 10 IHundred = Int(I / 10) If IHundred > 0 Then Result = Units(IHundred) & " Hundred" End If If ITen = 1 Then Result = Result & " " & Teens(IUnit) Else If ITen > 1 Then Result = Trim(Result & " " & Tens(ITen) & " " & Units(IUnit)) Else Result = Trim(Result & " " & Units(IUnit)) End If End If HundredsToText = Result End Function
Wide code split- Mod (GW)
Viewing 3 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Apple, Google stores still offer China-based VPNs, report says
by
Nibbled To Death By Ducks
6 hours, 12 minutes ago -
Search Forums only bring up my posts?
by
Deo
6 hours, 25 minutes ago -
Windows Spotlight broken on Enterprise and Pro for Workstations?
by
steeviebops
17 hours, 54 minutes ago -
Denmark wants to dump Microsoft for Linux + LibreOffice
by
Alex5723
10 hours, 31 minutes ago -
How to get Microsoft Defender to honor Group Policy Setting
by
Ralph
18 hours, 30 minutes ago -
Apple : Paragon’s iOS Mercenary Spyware Finds Journalists Target
by
Alex5723
1 day, 4 hours ago -
Music : The Rose Room – It’s Been A Long, Long Time album
by
Alex5723
1 day, 5 hours ago -
Disengage Bitlocker
by
CWBillow
19 hours, 43 minutes ago -
Mac Mini M2 Service Program for No Power Issue
by
Alex5723
1 day, 7 hours ago -
New Win 11 Pro Geekom Setup questions
by
Deo
6 hours, 21 minutes ago -
Windows 11 Insider Preview build 26200.5651 released to DEV
by
joep517
1 day, 15 hours ago -
Windows 11 Insider Preview build 26120.4441 (24H2) released to BETA
by
joep517
1 day, 15 hours ago -
iOS 26,, MacOS 26 : Create your own AI chatbot
by
Alex5723
1 day, 18 hours ago -
New PC transfer program recommendations?
by
DaveBoston
6 hours, 17 minutes ago -
Windows 11 Insider Preview Build 22631.5545 (23H2) released to Release Preview
by
joep517
1 day, 23 hours ago -
Windows 10 Build 19045.6029 (22H2) to Release Preview Channel
by
joep517
1 day, 23 hours ago -
Best tools for upgrading a Windows 10 to an 11
by
Susan Bradley
1 day, 11 hours ago -
The end of Windows 10 is approaching, consider Linux and LibreOffice
by
Alex5723
15 hours, 24 minutes ago -
Extended Windows Built-in Disk Cleanup Utility
by
bbearren
1 day ago -
Win 11 24H2 June 2025 Update breaks WIFI
by
dportenlanger
2 days, 18 hours ago -
Update from WinPro 10 v. 1511 on T460p?
by
CatoRenasci
1 day, 15 hours ago -
System Restore and Updates Paused
by
veteran
2 days, 20 hours ago -
Windows 10/11 clock app
by
Kathy Stevens
2 days, 7 hours ago -
Turn off right-click draw
by
Charles Billow
2 days, 23 hours ago -
Introducing ChromeOS M137 to The Stable Channel
by
Alex5723
3 days, 3 hours ago -
Brian Wilson (The Beach Boys) R.I.P
by
Alex5723
9 hours, 57 minutes ago -
Master patch listing for June 10, 2025
by
Susan Bradley
3 days, 4 hours ago -
Suggestions for New All in One Printer and a Photo Printer Windows 10
by
Win7and10
3 hours ago -
Purchasing New Printer. Uninstall old Printer Software First?
by
Win7and10
3 days, 10 hours ago -
KB5060842 Issue (Minor)
by
AC641
1 day, 23 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.