+ Start a Discussion
AnjaneyluAnjaneylu 

Convert number to Text format

Hi, 
Here my doubt is i want to convert the number to text format. 
here i used to TEXT(numberfield) in the formula field. but it is not working.
Ex: when a user enters 100 then the text format of the field has to display ONE HUNDRED. 

Please help me..

Thanks and Regards,
Anji reddy k
manpreetsaini26manpreetsaini26
Hey,

The class code is available here:
http://salesforcewithkiran.blogspot.in/2013/05/number-to-words-in-apex.html

Implementation using trigger with the help of above said class is mentioned here:
http://salesforce.stackexchange.com/questions/97612/trigger-for-converting-amountcurrency-number-to-words

Hope it helps...
kryzkryz
Since im pretty bored at the office today, I tried to come up with workaround without using an apex trigger. This formula can only handle up to "999" though. You can adjust this 'til Millions or whatever, just add some lines and tweak it. Just be reminded that if you add characters it might hit the character limit of the formula. You can do this via worfklow if you really wanted to add more. LOL. 
 
CASE(LEFT(TEXT(Enter_Number_Here__c / 100),1),
 "1", "ONE HUNDRED",
 "2", "TWO HUNDRED",
 "3", "THREE HUNDRED",
 "4", "FOUR HUNDRED",
 "5", "FIVE HUNDRED",
 "6", "SIX HUNDRED",
 "7", "SEVEN HUNDRED",
 "8", "EIGHT HUNDRED",
 "9", "NINE HUNDRED",
 ""
      )
& " " & 

CASE(
 LEFT(TEXT(MOD(Enter_Number_Here__c ,100) /10),1),
 "2", "TWENTY",
 "3", "THIRTY",
 "4", "FORTY",
 "5", "FIFTY",
 "6", "SIXTY",
 "7", "SEVENTY",
 "8", "EIGHTY",
 "9", "NINETY",
 "1", IF(LEFT(TEXT(MOD(Enter_Number_Here__c ,100)),2) = "10", "TEN", 
      IF(LEFT(TEXT(MOD(Enter_Number_Here__c ,100)),2) = "11", "ELEVEN", 
      IF(LEFT(TEXT(MOD(Enter_Number_Here__c ,100)),2) = "12", "TWELVE",
	  IF(LEFT(TEXT(MOD(Enter_Number_Here__c ,100)),2) = "13", "THIRTEEN",
	  IF(LEFT(TEXT(MOD(Enter_Number_Here__c ,100)),2) = "14", "FOURTEEN",
	  IF(LEFT(TEXT(MOD(Enter_Number_Here__c ,100)),2) = "15", "FIFTEEN",
	  IF(LEFT(TEXT(MOD(Enter_Number_Here__c ,100)),2) = "16", "SIXTEEN",
	  IF(LEFT(TEXT(MOD(Enter_Number_Here__c ,100)),2) = "17", "SEVENTEEN",
	  IF(LEFT(TEXT(MOD(Enter_Number_Here__c ,100)),2) = "18", "EIGHTEEN",
	  IF(LEFT(TEXT(MOD(Enter_Number_Here__c ,100)),2) = "19", "NINETEEN",
	  
""
	  )))))))))),
 
 ""
    )

& " " & 

IF(LEFT(TEXT(MOD(Enter_Number_Here__c ,100) /10),1) <> "1",
CASE(
TEXT(MOD(
   MOD(Enter_Number_Here__c  ,100),10)),
 "1", "ONE",
 "2", "TWO",
 "3", "THREE",
 "4", "FOUR",
 "5", "FIVE",
 "6", "SIX",
 "7", "SEVEN",
 "8", "EIGHT",
 "9", "NINE",
""
    ), "")