Skip to main content

Numbers To Text Function

Please Watch the below Video to act Upon and then Apply this code to use in your daily regime activity 

Numbers To Text Function

Copy this all and paste in developer tab and run the code 

Function NumberToWords(ByVal MyNumber)

    Dim Units As String

    Dim Tens As String

    Dim Hundreds As String

    Dim Thousands As String

    Dim TempStr As String

    Dim DecimalPlace As Integer

    Dim Count As Integer

    Dim DecimalValue As String


    ReDim Place(9) As String

    Place(2) = " Thousand "

    Place(3) = " Million "

    Place(4) = " Billion "

    Place(5) = " Trillion "


    MyNumber = Trim(CStr(MyNumber))

    DecimalPlace = InStr(MyNumber, ".")

    If DecimalPlace > 0 Then

        DecimalValue = Mid(MyNumber, DecimalPlace + 1)

        MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))

    End If


    Count = 1

    Do While MyNumber <> ""

        TempStr = GetHundreds(Right(MyNumber, 3))

        If TempStr <> "" Then

            Units = TempStr & Place(Count) & Units

        End If

        If Len(MyNumber) > 3 Then

            MyNumber = Left(MyNumber, Len(MyNumber) - 3)

        Else

            MyNumber = ""

        End If

        Count = Count + 1

    Loop


    NumberToWords = Application.Trim(Units)

    If DecimalValue <> "" Then

        NumberToWords = NumberToWords & " and " & DecimalValue & "/100"

    End If

End Function


Function GetHundreds(ByVal MyNumber)

    Dim Result As String

    If Val(MyNumber) = 0 Then Exit Function

    MyNumber = Right("000" & MyNumber, 3)

    If Mid(MyNumber, 1, 1) <> "0" Then

        Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "

    End If

    If Mid(MyNumber, 2, 1) <> "0" Then

        Result = Result & GetTens(Mid(MyNumber, 2))

    Else

        Result = Result & GetDigit(Mid(MyNumber, 3))

    End If

    GetHundreds = Result

End Function


Function GetTens(TensText)

    Dim Result As String

    Result = ""         

    If Val(Left(TensText, 1)) = 1 Then   

        Select Case Val(TensText)

            Case 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                                

        Select Case Val(Left(TensText, 1))

            Case 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 = Result & GetDigit(Right(TensText, 1))

    End If

    GetTens = Result

End Function


Function GetDigit(Digit)

    Select Case Val(Digit)

        Case 1: GetDigit = "One"

        Case 2: GetDigit = "Two"

        Case 3: GetDigit = "Three"

        Case 4: GetDigit = "Four"

        Case 5: GetDigit = "Five"

        Case 6: GetDigit = "Six"

        Case 7: GetDigit = "Seven"

        Case 8: GetDigit = "Eight"

        Case 9: GetDigit = "Nine"

        Case Else: GetDigit = ""

    End Select

End Function


Comments

Popular posts from this blog

Add Checkboxes in Excel and Automate

 How to Add Checkboxes in Excel and Automate Time Tracking Time management and productivity tracking are crucial in business, and Excel provides a simple yet effective way to streamline these tasks. If you want to add checkboxes in Excel and automate check-in and check-out times, this guide will help you get started. Many users struggle to find the checkbox feature in Excel. If the option is missing on your system, we’ll show you how to activate the Developer tab and insert checkboxes effortlessly. Once enabled, you can link checkboxes to a formula that automatically records time as soon as you check in or out.This method is ideal for: Gantt charts to track project progress Project management templates for task assignments Employee attendance tracking to monitor work hours Downtime monitoring for workflow efficiency Productivity tracking to analyze performance By integrating this feature into your workflow, you can save time, eliminate manual errors, and improve efficiency...

How to Read Box and Whisker Plot

How to Read Box and Whisker Plot Welcome to Discover talent Presents we got more than 30 requests on Meta, we are finally creating a detailed explanation of the Box and Whisker Plot for you, our valued followers. This will help you make informed business decisions based on data analysis. we've broken down each part of the Box and Whisker Plot to explain how it works, how to read it, and how to use it for strategic decision-making. By understanding this chart, you will be able to make better, more data-driven business choices.   For the complete walkthrough, make sure to watch the video below. We’ve used background music from YouTube, so we cannot use the same music outside of YouTube. We encourage you to click the link below, watch the video, and gain insights that will save you time and help you become smarter in your business practices.  Watch the full video here: Box and Whisker Plot | How to Read & Use Box Plot in Excel for Strategic Decisions What is a Box...

Basics Function of Ms Excel

 We have published more than 80 videos which are covering ms excel basic to advance. We also provide free ms excel certification which you add in your resume or CV . which creates value for your career . We share excel expertise on this channel ( #QuickExcelHacks , #ExcelTips, #MsExcelTraining , #MsExcel and #MsOffice Guide ) Free of cost ( no hidden charges ) urge you to subscribe us to upskill yourself  हमने 80 से अधिक वीडियो प्रकाशित किए हैं जो आगे बढ़ने के लिए एमएस एक्सेल बेसिक को कवर कर रहे हैं। हम मुफ्त एमएस एक्सेल सर्टिफिकेशन भी प्रदान करते हैं जिसे आप अपने रिज्यूम या सीवी में जोड़ते हैं। जो अपने कैरियर के लिए वैल्यू बनाता है . हम इस चैनल पर एक्सेल विशेषज्ञता साझा करते हैं (#QuickExcelHacks, #ExcelTips, #MsExcelTraining, #MsExcel और #MsOffice गाइड) मुफ्त (कोई छिपा शुल्क नहीं) आपसे आग्रह करते हैं कि आप हमें अपने आप को उप-कौशल प्रदान करने के लिए सदस्यता लें Discover Talent Presents | Ms Excel training - You Should Know These Basic Functions of Excel - LIVE here you should...