Result = Result & ConvertDigit(Mid(MyNumber, 3))Įnd Function Private Function ConvertTens (ByVal MyTens) ' If not, then convert the ones place digit. Result = Result & ConvertTens(Mid(MyNumber, 2)) ' Do we have a tens place digit to convert? Result = ConvertDigit(Left(MyNumber, 1)) & " Hundred " ' Do we have a hundreds place digit to convert? MyNumber = Left(MyNumber, Len(MyNumber) - 3)ĬonvertCurrencyToEnglish = Dollars & CentsĮnd Function Private Function ConvertHundreds (ByVal MyNumber) ' Remove last 3 converted digits from MyNumber. If Temp "" Then Dollars = Temp & Place(Count) & Dollars Temp = ConvertHundreds(Right(MyNumber, 3)) ' Convert last 3 digits of MyNumber to English dollars. MyNumber = Trim(Left(MyNumber, DecimalPlace - 1)) ' Strip off cents from remainder to convert. Temp = Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2) ' Convert MyNumber to a string, trimming extra spaces. Function ConvertCurrencyToEnglish (ByVal MyNumber) Type the following code into the module sheet. In Microsoft Excelĥ.0 or 7.0, point to Macro on the Insert menu and click Module.Ģ. In the Visual Basic Editor, click Module on the Insert menu. To do this in Microsoft Excel 97 or MicrosoftĮxcel 98, point to Macro on the Tools menu, and then click Visual Basic Editor. Select ConvertCurrencyToEnglish, and enter your number or cell reference.ġ. Click the Function Wizard button, and select User Defined under Function Category.Ģ. To use the Function Wizard, follow these steps:ġ. The Function Wizard can also be used to enter a custom function in a worksheet. Will return the following words for the number 1234.56: One Thousand Two Hundred To convert a numeric value to an English word representation. This article shows you how to create a sample, user-defined function named ConvertCurrencyToEnglish() Here is a very popular bit of code from Microsoft that willĬonvert any currency amount in a cell to English words.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |