Home » excel » Convert Excel value to words (in English)

# Convert Excel value to words (in English)

Questions:

I found this formula to convert amounts into words, but it does not work 100%. Whenever an amount ends with 20,30, 40 etc it gives an error. For example 1020 will give an error but 1019 and 1021 will work fine. I have tried to fix this myself but no luck. It has to be formula (the software (Google Docs) it interfaces with cannot handle VBA scripting.

Here is the formula :

``````=IF(H53<10^12,
IF(INT(H53/10^9)>0,
IF(INT(H53/10^11)>0,
INDEX(
{"One ","Two ","Three","Four ","Five ","Six ","Seven ","Eight ","Nine "},
MATCH(INT(H53/10^11),{1,2,3,4,5,6,7,8,9})
)&"Hundred ",
"")&
IF(MOD(INT(H53/10^9),100)<20,
INDEX(
{"","One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine ","Ten ",
"Eleven ","Twelve","Thirteen","Fourteen ","Fifteen","Sixteen","Seventeen","Eighteen ","Nineteen"},
MATCH(MOD(INT(H53/10^9),100),{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19})
),
INDEX(
{"","Twenty ","Thirty ","Fourty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninety "},
MATCH(INT(MOD(INT(H53/10^9),100)/10),{1,2,3,4,5,6,7,8,9})
)&
INDEX(
{"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
MATCH(MOD(INT(H53/10^9),10),{1,2,3,4,5,6,7,8,9})
)
)&" Billion  ",
""
)&
IF(MOD(INT(H53/10^6),10^3)>0,
IF(INT(MOD(INT(H53/10^6),10^3)/100)>0,
INDEX(
{"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
MATCH(INT(MOD(INT(H53/10^6),10^3)/100),{1,2,3,4,5,6,7,8,9})
)&"Hundred ",
"")&
IF(MOD(INT(H53/10^6),100)<20,
INDEX(
{"","One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine ","Ten ",
"Eleven ","Twelve","Thirteen","Fourteen ","Fifteen ","Sixteen","Seventeen","Eighteen ","Nineteen"},
MATCH(MOD(INT(H53/10^6),100),{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19})
),
INDEX(
{"","Twenty ","Thirty ","Fourty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninety "},
MATCH(INT(MOD(INT(H53/10^6),100)/10),{1,2,3,4,5,6,7,8,9})
)&
INDEX(
{"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
MATCH(MOD(INT(H53/10^6),10),{1,2,3,4,5,6,7,8,9})
)
)&" Million  ",
""
)&
IF(MOD(INT(H53/10^3),10^3)>0,
IF(INT(MOD(INT(H53/10^3),10^3)/100)>0,
INDEX(
{"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
MATCH(INT(MOD(INT(H53/10^3),10^3)/100),{1,2,3,4,5,6,7,8,9})
)&"Hundred ",
"")&
IF(MOD(INT(H53/10^3),100)<20,
INDEX(
{"","One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine ","Ten ",
"Eleven ","Twelve","Thirteen","Fourteen ","Fifteen ","Sixteen","Seventeen","Eighteen ","Nineteen"},
MATCH(MOD(INT(H53/10^3),100),{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19})
),
INDEX(
{"","Twenty ","Thirty ","Fourty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninety "},
MATCH(INT(MOD(INT(H53/10^3),100)/10),{1,2,3,4,5,6,7,8,9})
)&
INDEX(
{"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
MATCH(MOD(INT(H53/10^3),10),{1,2,3,4,5,6,7,8,9})
)
)&" Thousand  ",
""
)&
IF(MOD(MOD(H53,10^4),10^3)>0,
IF(INT(MOD(MOD(H53,10^4),10^3)/100)>0,
INDEX(
{"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
MATCH(INT(MOD(MOD(H53,10^4),10^3)/100),{1,2,3,4,5,6,7,8,9})
)&"Hundred ",
""
)&
IF(MOD(MOD(MOD(H53,10^4),10^3),100)<20,
INDEX(
{"","One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine ","Ten ",
"Eleven ","Twelve","Thirteen","Fourteen ","Fifteen ","Sixteen","Seventeen","Eighteen ","Nineteen"},
MATCH(MOD(MOD(MOD(H53,10^4),10^3),100),{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19})
),
INDEX(
{"","Twenty ","Thirty ","Fourty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninety "},
MATCH(INT(MOD(MOD(MOD(H53,10^4),10^3),100)/10),{1,2,3,4,5,6,7,8,9})
)&
INDEX(
{"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
MATCH(MOD(MOD(MOD(H53,10^4),10^3),10),{1,2,3,4,5,6,7,8,9})
)
),
""
),
""
) & " Rands"
``````

The problem lies in the last part:

`````` INDEX({"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
MATCH(MOD(MOD(MOD(H53,10^4),10^3),10),{1,2,3,4,5,6,7,8,9})
``````

`MOD(MOD(MOD(H53,10^4),10^3),10)` will return `0`, which is not found in 1-9.

Therefore, the above line should be modified to:

`````` INDEX({"", "One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
MATCH(MOD(MOD(MOD(H53,10^4),10^3),10),{0, 1,2,3,4,5,6,7,8,9})
``````

This problem also exists in other areas of the formula.

All is fixed in this full formula (it also adds a few spaces that were inconsistently left out):

``````=IF(B1<10^12,
IF(INT(B1/10^9)>0,
IF(INT(B1/10^11)>0,
INDEX(
{"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
MATCH(INT(B1/10^11),{1;2;3;4;5;6;7;8;9})
)&"Hundred ",
"")&
IF(MOD(INT(B1/10^9),100)<20,
INDEX(
{"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine ";"Ten ";"Eleven ";"Twelve ";"Thirteen ";"Fourteen ";"Fifteen ";"Sixteen ";"Seventeen ";"Eighteen ";"Nineteen "},
MATCH(MOD(INT(B1/10^9),100),{0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19})
),
INDEX(
{"";"Twenty ";"Thirty ";"Fourty ";"Fifty ";"Sixty ";"Seventy ";"Eighty ";"Ninety "},
MATCH(INT(MOD(INT(B1/10^9),100)/10),{1;2;3;4;5;6;7;8;9})
)&
INDEX(
{"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
MATCH(MOD(INT(B1/10^9),10),{0;1;2;3;4;5;6;7;8;9})
)
)&" Billion  ",
""
)&
IF(MOD(INT(B1/10^6),10^3)>0,
IF(INT(MOD(INT(B1/10^6),10^3)/100)>0,
INDEX(
{"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
MATCH(INT(MOD(INT(B1/10^6),10^3)/100),{0;1;2;3;4;5;6;7;8;9})
)&"Hundred ",
"")&
IF(MOD(INT(B1/10^6),100)<20,
INDEX(
{"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine ";"Ten ";"Eleven ";"Twelve ";"Thirteen ";"Fourteen ";"Fifteen ";"Sixteen ";"Seventeen ";"Eighteen ";"Nineteen "},
MATCH(MOD(INT(B1/10^6),100),{0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19})
),
INDEX(
{"";"Twenty ";"Thirty ";"Fourty ";"Fifty ";"Sixty ";"Seventy ";"Eighty ";"Ninety "},
MATCH(INT(MOD(INT(B1/10^6),100)/10),{1;2;3;4;5;6;7;8;9})
)&
INDEX(
{"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
MATCH(MOD(INT(B1/10^6),10),{0;1;2;3;4;5;6;7;8;9})
)
)&" Million  ",
""
)&
IF(MOD(INT(B1/10^3),10^3)>0,
IF(INT(MOD(INT(B1/10^3),10^3)/100)>0,
INDEX(
{"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
MATCH(INT(MOD(INT(B1/10^3),10^3)/100),{0;1;2;3;4;5;6;7;8;9})
)&"Hundred ",
"")&
IF(MOD(INT(B1/10^3),100)<20,
INDEX(
{"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine ";"Ten ";"Eleven ";"Twelve ";"Thirteen ";"Fourteen ";"Fifteen ";"Sixteen ";"Seventeen ";"Eighteen ";"Nineteen "},
MATCH(MOD(INT(B1/10^3),100),{0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19})
),
INDEX(
{"";"Twenty ";"Thirty ";"Fourty ";"Fifty ";"Sixty ";"Seventy ";"Eighty ";"Ninety "},
MATCH(INT(MOD(INT(B1/10^3),100)/10),{1;2;3;4;5;6;7;8;9})
)&
INDEX(
{"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
MATCH(MOD(INT(B1/10^3),10),{0;1;2;3;4;5;6;7;8;9})
)
)&" Thousand  ",
""
)&
IF(MOD(MOD(B1,10^4),10^3)>0,
IF(INT(MOD(MOD(B1,10^4),10^3)/100)>0,
INDEX(
{"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
MATCH(INT(MOD(MOD(B1,10^4),10^3)/100),{0;1;2;3;4;5;6;7;8;9})
)&"Hundred ",
""
)&
IF(MOD(MOD(MOD(B1,10^4),10^3),100)<20,
INDEX(
{"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine ";"Ten ";"Eleven ";"Twelve ";"Thirteen ";"Fourteen ";"Fifteen ";"Sixteen ";"Seventeen ";"Eighteen ";"Nineteen "},
MATCH(MOD(MOD(MOD(B1,10^4),10^3),100),{0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19})
),
INDEX(
{"";"Twenty ";"Thirty ";"Fourty ";"Fifty ";"Sixty ";"Seventy ";"Eighty ";"Ninety "},
MATCH(INT(MOD(MOD(MOD(B1,10^4),10^3),100)/10),{1;2;3;4;5;6;7;8;9})
)&
INDEX(
{"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
MATCH(MOD(MOD(MOD(B1,10^4),10^3),10),{0;1;2;3;4;5;6;7;8;9})
)
),
""
),
""
) & " Rands"
``````