Changing Number to Text
D

1

1

I currently using this code in Google Sheet to replace my numbers(Currency) to text. But its showing error for this part

IF(IFERROR(QUERY({Y:Y},"where Col1 Contains '.'"),)<>"", " and "&REGEXEXTRACT(TO_TEXT(Y:Y), "\.(.+)")&" cents", ))," ", " ")

What should I change to make it work properly?

My full code below: =ARRAYFORMULA(IFS(ROW(AQ:AQ)=1,"WageWords",A:A="","",TRUE,REGEXREPLACE(IF(OR(LEN(FLOOR(Y:Y,1))>=13,FLOOR(Y:Y,1)<=0),"", PROPER(SUBSTITUTE(CONCATENATE(CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),1,1)+1,"","one hundred ","two hundred ","three hundred ","four hundred ","five hundred ","six hundred ","seven hundred ","eight hundred ","nine hundred "), CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),2,1)+1,"",CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),3,1)+1,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"),"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"), IF(VALUE(MID(TEXT(INT(Y:Y), REPT(0,12)),2,1))>1,CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),3,1)+1,"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine"), IF(VALUE(MID(TEXT(INT(Y:Y), REPT(0,12)),2,1))=0,CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),3,1)+1,"","one","two","three","four","five","six","seven","eight","nine"),"")), IF(Y:Y>=10^9," billion ",""), CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),4,1)+1,"","one hundred ","two hundred ","three hundred ","four hundred ","five hundred ","six hundred ","seven hundred ","eight hundred ","nine hundred "), CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),5,1)+1,"",CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),6,1)+1,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"),"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"), IF(VALUE(MID(TEXT(INT(Y:Y), REPT(0,12)),5,1))>1,CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),6,1)+1,"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine"), IF(VALUE(MID(TEXT(INT(Y:Y), REPT(0,12)),5,1))=0,CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),6,1)+1,"","one","two","three","four","five","six","seven","eight","nine"),"")), IF(VALUE(MID(TEXT(INT(Y:Y), REPT(0,12)),4,3))>0," million ",""),CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),7,1)+1,"","one hundred ","two hundred ","three hundred ","four hundred ","five hundred ","six hundred ","seven hundred ","eight hundred ","nine hundred "), CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),8,1)+1,"",CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),9,1)+1,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"),"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"), IF(VALUE(MID(TEXT(INT(Y:Y), REPT(0,12)),8,1))>1,CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),9,1)+1,"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine"), IF(VALUE(MID(TEXT(INT(Y:Y), REPT(0,12)),8,1))=0,CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),9,1)+1,"","one","two","three","four","five","six","seven","eight","nine"),"")), IF(VALUE(MID(TEXT(INT(Y:Y), REPT(0,12)),7,3))," thousand ",""),CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),10,1)+1,"","one hundred ","two hundred ","three hundred ","four hundred ","five hundred ","six hundred ","seven hundred ","eight hundred ","nine hundred "), CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),11,1)+1,"",CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),12,1)+1,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"),"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"), IF(VALUE(MID(TEXT(INT(Y:Y), REPT(0,12)),11,1))>1,CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),12,1)+1,"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine"), IF(VALUE(MID(TEXT(INT(Y:Y), REPT(0,12)),11,1))=0,CHOOSE(MID(TEXT(INT(Y:Y), REPT(0,12)),12,1)+1,"","one","two","three","four","five","six","seven","eight","nine"),"")))," "," "))& IF(IFERROR(QUERY({Y:Y},"where Col1 Contains '.'"),)<>"", " and "&REGEXEXTRACT(TO_TEXT(Y:Y), "\.(.+)")&" cents", ))," ", " ")))

Dunstan answered 20/4, 2022 at 4:46 Comment(1)
Use custom function. See this article. msofficegeek.com/spellnumber-indian-rupeesForegoing
S
1

use:

=ARRAYFORMULA(IF(Y:Y="",,REGEXREPLACE(IF((LEN(FLOOR(Y:Y,1))>=13)+(FLOOR(Y:Y,1)<=0),"Out of range",
 PROPER(SUBSTITUTE((CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),1,1)+1,"","one hundred ","two hundred ","three hundred ","four hundred ","five hundred ","six hundred ","seven hundred ","eight hundred ","nine hundred ")&
 CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),2,1)+1,"",CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),3,1)+1,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"),"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety")&
 IF(VALUE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),2,1))>1,CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),3,1)+1,"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine"),
 IF(VALUE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),2,1))=0,CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),3,1)+1,"","one","two","three","four","five","six","seven","eight","nine"),""))&
 IF(Y:Y>=10^9," billion ","")&
 CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),4,1)+1,"","one hundred ","two hundred ","three hundred ","four hundred ","five hundred ","six hundred ","seven hundred ","eight hundred ","nine hundred ")&
 CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),5,1)+1,"",CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),6,1)+1,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"),"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety")&
 IF(VALUE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),5,1))>1,CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),6,1)+1,"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine"),
 IF(VALUE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),5,1))=0,CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),6,1)+1,"","one","two","three","four","five","six","seven","eight","nine"),""))&
 IF(VALUE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),4,3))>0," million ","")&CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),7,1)+1,"","one hundred ","two hundred ","three hundred ","four hundred ","five hundred ","six hundred ","seven hundred ","eight hundred ","nine hundred ")&
 CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),8,1)+1,"",CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),9,1)+1,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"),"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety")&
 IF(VALUE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),8,1))>1,CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),9,1)+1,"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine"),
 IF(VALUE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),8,1))=0,CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),9,1)+1,"","one","two","three","four","five","six","seven","eight","nine"),""))&
 IF(VALUE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),7,3))," thousand ","")&CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),10,1)+1,"","one hundred ","two hundred ","three hundred ","four hundred ","five hundred ","six hundred ","seven hundred ","eight hundred ","nine hundred ")&
 CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),11,1)+1,"",CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),12,1)+1,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"),"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety")&
 IF(VALUE(MID(TEXT(INT(Y:Y), 
 REPT(0,12)),11,1))>1,CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),12,1)+1,"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine"),
 IF(VALUE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),11,1))=0,CHOOSE(MID(TEXT(INT(Y:Y),
 REPT(0,12)),12,1)+1,"","one","two","three","four","five","six","seven","eight","nine"),""))),"  "," "))&
 IFERROR(IF(REGEXMATCH(TO_TEXT(Y:Y), "\."), 
 " and "&REGEXEXTRACT(TO_TEXT(Y:Y), "\.(.+)")&" cents", ))),"  ", " ")))

enter image description here

Skippy answered 20/4, 2022 at 8:22 Comment(3)
I want it to run for the entire column. Right now, your function works only for A1 not entire column of A. Whenever new google form data enters, I want the data to convert the number(currency) to text. For it to happen I need it to cover entire column.Dunstan
@Dunstan answer updated. try nowSkippy
Thanks. It works perfectly with my sheet now. I try to do something similar by removing the query line but it didn't work for me. Thank you!Dunstan

© 2022 - 2024 — McMap. All rights reserved.