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 "®EXEXTRACT(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 "®EXEXTRACT(TO_TEXT(Y:Y), "\.(. )")&" cents", ))," ", " ")))
CodePudding user response:
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 "®EXEXTRACT(TO_TEXT(Y:Y), "\.(. )")&" cents", )))," ", " ")))