SPELLNUMBER

=SPELLNUMBER(range)

range
range of cells with numbers to be spelled out

SPELLNUMBER takes a number and converts it to spelled out words

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
3,957
Office Version
  1. 365
Platform
  1. Windows
SPELLNUMBER takes a number and converts it to spelled out words. There are a number of helper Lambdas which are also listed.

SPELLNUMBER
Excel Formula:
=LAMBDA(range,
    MAP(range,
        LAMBDA(n,
            LET(
                buckets,SPLITNUM(ZPAD(n)),
                r,ROWS(buckets),
                t,MAP(buckets,LAMBDA(b,HUNDRED(ARRAYFROMTEXT(b)))),
                z,INDEX(HUGE(),SEQUENCE(r,,r,-1)),
                    TEXTJOIN(" ",,t&" "&z)
            )
        )
    )
)

SML
Excel Formula:
=LAMBDA(LET(sml,{"";"one";"two";"three";"four";"five";"six";"seven";"eight";"nine";"ten";"eleven";"twelve";"thirteen";"fourteen";"fifteen";"sixteen";"seventeen";"eighteen";"nineteen"},sml))

TENS
Excel Formula:
=LAMBDA(LET(tens,{"";"twenty";"thirty";"forty";"fifty";"sixty";"seventy";"eighty";"ninety"},tens))

HUGE
Excel Formula:
=LAMBDA(LET(huge,{"";"thousand";"million";"billion";"trillion";"quadrillion";"quintillion";"sextillion";"septillion";"octillion";"nonillion";"decillion"},huge))

HOR
Excel Formula:
=LAMBDA(input,IF(input="0","",INDEX(SML(),input+1) & " hundred"))

ZPAD
Excel Formula:
=LAMBDA(text,REPT("0",MOD(3-MOD(LEN(text),3),3))&text)

TEXTREVERSE
Excel Formula:
=LAMBDA(text,LET(cnt,LEN(text),TEXTJOIN(,,MID(text,SEQUENCE(cnt,,cnt,-1),1))))

HYPHENATE
Excel Formula:
=LAMBDA(text,chunk_size,
    MAP(text,
        LAMBDA(t,
            TEXTJOIN("-",,MID(t,SEQUENCE(ROUNDUP(LEN(t)/chunk_size,0),,,chunk_size),chunk_size))
        )
    )
)

Spell Numbers
AB
1NumberSpell
24four
312twelve
4314three hundred fourteen
52,145two thousand one hundred forty five
678,542seventy eight thousand five hundred forty two
7652,145six hundred fifty two thousand one hundred forty five
84,521,456four million five hundred twenty one thousand four hundred fifty six
985,452,145eighty five million four hundred fifty two thousand one hundred forty five
10362,514,789three hundred sixty two million five hundred fourteen thousand seven hundred eighty nine
Sheet6
Cell Formulas
RangeFormula
B2:B10B2=SPELLNUMBER(A2:A10)
Dynamic array formulas.
 
Upvote 0
1679636019241.png
 
Forgot this one is needed as well.

ARRAYFROMTEXT
Excel Formula:
=LAMBDA(text,[to_rows],LET(a,text,n,LEN(a),r,MID(a,SEQUENCE(n),1),IF(ISOMITTED(to_rows),r,IF(to_rows,r,TRANSPOSE(r)))))
 
I forgot to add SPLITNUM and HUNDRED.

Thanks for pointing this out.

SPLITNUM
Excel Formula:
=LAMBDA(text,
    TEXTSPLIT(TEXTREVERSE(INDEX(HYPHENATE(TEXTREVERSE(text),3),1)),,"-")
)

HUNDRED
Excel Formula:
=LAMBDA(text,
    LET(
        r,text,
        a,INDEX(r,1),
        b,INDEX(r,2),
        c,INDEX(r+1,3),
        x,IF(INT(b)<2,
            INDEX(SML(),b&c),
            INDEX(TENS(),b) & " " & INDEX(SML(),c)
            ),
        TRIM(HOR(a) &" " & x)
    )
)
 
Hi, I think your function returns an error for numbers ending, starting with, or containing "19". Instead of debugging it, it was simpler for me to write a new function from scratch. 😉
Can you check?
SPELLNR(ar) calls SD([k]) Spell Digits
ar
: array of numbers (can be in text format for large numbers (keeps precision) or numbers in general or number format)
Excel Formula:
=LAMBDA(ar,
    LET(
        f, LAMBDA(n,
            LET(
                t, REPT(0, 36 - LEN(n)) & n,
                m, --MID(t, SEQUENCE(36), 1),
                w, WRAPROWS(m, 3),
                a, TAKE(w, , 1),
                b, INDEX(w, , 2),
                c, TAKE(w, , -1),
                x, INDEX(SD(), a + 1),
                y, INDEX(SD(1), b),
                z, INDEX(SD(), IF(b = 1, c + 10, c) + 1),
                g, TRIM(x & " " & IF(x = "", "", SD(3)) & " " & y & " " & z),
                TRIM(TEXTJOIN(" ", , IF(g = "", "", g & " " & SD(2))))
            )
        ),
        MAP(ar, f)
    )
)

SD([k]) Spell Digits, contains all the names in one place, compact form, easy to change if we need spelling in other languages,
k= omitted/0,1,2,3
Excel Formula:
=LAMBDA([k],SWITCH(k,1,{"";"twenty";"thirty";"forty";"fifty";"sixty";"seventy";"eighty";"ninety"},2,{"decillion";"nonillion";"octillion";"septillion";"sextillion";"quintillion";"quadrillion";"trillion";"billion";"million";"thousand";""},3,"hundred",{"";"one";"two";"three";"four";"five";"six";"seven";"eight";"nine";"ten";"eleven";"twelve";"thirteen";"fourteen";"fifteen";"sixteen";"seventeen";"eighteen";"nineteen"}))
this is what SD returns for different k values
Book2.xlsx
ABCDEFGHI
1k argument values
2
3=SD()=SD(1)=SD(2)=SD(3)
4  decillionhundred
5onetwentynonillion
6twothirtyoctillion
7threefortyseptillion
8fourfiftysextillion
9fivesixtyquintillion
10sixseventyquadrillion
11seveneightytrillion
12eightninetybillion
13ninemillion
14tenthousand
15eleven
16twelve
17thirteenNote: Empty strings at the beginning or at the end of vectors
18fourteenhave a deliberate functionality purpose 😉
19fifteen
20sixteen
21seventeen
22eighteen
23nineteen
24
Sheet9
Cell Formulas
RangeFormula
B3,H3,F3,D3B3=FORMULATEXT(B4)
B4:B23B4=SD()
D4:D12D4=SD(1)
F4:F15F4=SD(2)
H4H4=SD(3)
Dynamic array formulas.


The errors:
Book2.xlsx
ABCDEFGHI
1
2
3=SPELLNUMBER(B4:D8)
41919545119010#REF!#REF!#REF!
521919592119042#REF!#REF!#REF!
6231919594219229#REF!#REF!#REF!
72341919564219230#REF!#REF!#REF!
811943193245191one thousand one hundred ninety four thirty one thousand nine hundred thirty two forty five thousand one hundred ninety one
9
10
11=SPELLNR(B4:D8)
12nineteennineteen thousand five hundred forty fiveone hundred nineteen thousand ten
13two hundred nineteennineteen thousand five hundred ninety twoone hundred nineteen thousand forty two
14two thousand three hundred nineteennineteen thousand five hundred ninety fourtwo hundred nineteen thousand two hundred twenty nine
15twenty three thousand four hundred nineteennineteen thousand five hundred sixty fourtwo hundred nineteen thousand two hundred thirty
16one thousand one hundred ninety fourthirty one thousand nine hundred thirty twoforty five thousand one hundred ninety one
17
Sheet1
Cell Formulas
RangeFormula
F3,F11F3=FORMULATEXT(F4)
F4:H8F4=SPELLNUMBER(B4:D8)
F12:H16F12=SPELLNR(B4:D8)
Dynamic array formulas.
 
I just went through and saw how your version works. Very cool! I especially like the use of WRAPROWS. Much more elegant than how I was doing it.

I am not sure why you were having the issues with the number 19. Seems to be working on my end.

Insert Hyphens Spell Words II.xlsm
AB
1NumberSpell
219nineteen
3219two hundred nineteen
41,984one thousand nine hundred eighty four
519,469nineteen thousand four hundred sixty nine
Sheet6
Cell Formulas
RangeFormula
B2:B10B2=SPELLNUMBER(A2:A10)
Dynamic array formulas.
 
Uf...There is no "weird" in Excel, everything has an explanation.
Quite simply, the problem is with your HUNDRED function. You can correct it now. 😉
Excel Formula:
=LAMBDA(text,
    LET(
        r,text,
        a,INDEX(r,1),
        b,INDEX(r,2),
        c,INDEX(r+1,3),
        x,IF(INT(b)<2,
            INDEX(SML(),b&c),
            INDEX(TENS(),b) & " " & INDEX(SML(),c)
            ),
        TRIM(HOR(a) &" " & x)
    )
)
spellnumber error.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1
2118
3
4=LAMBDA(text, LET( r,text, a,INDEX(r,1), b,INDEX(r,2), c,INDEX(r+1,3), x,IF(INT(b)<2, INDEX(SML(),b&c), INDEX(TENS(),b) & " " & INDEX(SML(),c) ), TRIM(HOR(a) &" " & x) ) )(B2:D2)
5one hundred eighteen
6
7variables: b=1 , c=9, b&c=19 => x=INDEX(SML(),19) = eighteen => numbers ending in 18 or <=18 are ok
8
9
10
11119
12
13=LAMBDA(text, LET( r,text, a,INDEX(r,1), b,INDEX(r,2), c,INDEX(r+1,3), x,IF(INT(b)<2, INDEX(SML(),b&c), INDEX(TENS(),b) & " " & INDEX(SML(),c) ), TRIM(HOR(a) &" " & x) ) )(B11:D11)
14#REF!
15
16variables: b=1 , c=10, b&c=110 => x=INDEX(SML(),110) => #REF error b&c should deliver 20 instead of 110
17
Sheet2
Cell Formulas
RangeFormula
B4,B13B4=FORMULATEXT(B5)
B5,B14B5=LAMBDA(text, LET( r,text, a,INDEX(r,1), b,INDEX(r,2), c,INDEX(r+1,3), x,IF(INT(b)<2, INDEX(SML(),b&c), INDEX(TENS(),b) & " " & INDEX(SML(),c) ), TRIM(HOR(a) &" " & x) ) )(B2:D2)
 

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top