![]() ![]() (Right(TensText, 1)) ' Retrieve ones place. ![]() If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19… Select Case Val(TensText)Ĭase 10: Result = "Ten" Case 11: Result = "Eleven" Case 12: Result = "Twelve" Case 13: Result = "Thirteen" Case 14: Result = "Fourteen" Case 15: Result = "Fifteen" Case 16: Result = "Sixteen" Case 17: Result = "Seventeen" Case 18: Result = "Eighteen" Case 19: Result = "Nineteen" Case Else End Select Else ' If value between 20-99… Select Case Val(Left(TensText, 1))Ĭase 2: Result = "Twenty " Case 3: Result = "Thirty " Case 4: Result = "Forty " Case 5: Result = "Fifty " Case 6: Result = "Sixty " Case 7: Result = "Seventy " Case 8: Result = "Eighty " Case 9: Result = "Ninety " Case Else End Select Result = "" ' Null out the temporary function value. Result = Result & GetDigit(Mid(MyNumber, 3)) Result = Result & GetTens(Mid(MyNumber, 2)) Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred " End If ' Convert the tens and ones place. MyNumber = Left(MyNumber, Len(MyNumber) - 3)ĭollars = Dollars & " Dollars" End Select Select Case CentsĬents = " and " & Cents & " Cents" End SelectĮnd Function Function GetHundreds( ByVal MyNumber)ĭim Result As String If Val(MyNumber) = 0 Then Exit Function If Temp "" Then Dollars = Temp & Place(Count) & Dollars MyNumber = Trim(Left(MyNumber, DecimalPlace - 1)) Option Explicit 'Main Function Function SpellNumber( ByVal MyNumber)Ĭents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _ Select all of the code in the frame below and paste it to this window. You should see a window named YourBook - Module1.In the editor menu go to Insert-> Module.If you have several books opened, check that the needed workbook is active using the list of projects in the upper left corner of the editor (one of the workbook elements is highlighted with blue). ![]() Press Alt+F11 to open the Visual Basic editor window.Open the workbook where you need to spell the numbers.If you still don't want or haven't time to sort this out, please use this solution. If you are not a VBA savvy guy, below you will find a copy of the code. If you need a different currency, you can change " dollar" and " cent" with the name of your one. The spellnumber option is able to write dollars and cents. However, it is not a formula, but a macro function, or to be more precise Excel User defined function (UDF). You can find the macro mentioned as "spellnumber formula". All other macros I came across are based on the Microsoft code. The macro does what its name SpellNumber suggests. However, when they saw how many users needed it, they created and published the special VBA macro on their website. ![]() SpellNumber VBA macro to convert numbers to wordsĪs I have already mentioned, Microsoft didn't want to add a tool for this task.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |