Friday, October 30, 2020

Excel -ல் எண் எழுத்தில்.

 


நாம் எக்ஸல்லில் சில டாக்குமெண்ட் தயாரிக்கும்பொழுது எண் மதிப்பை எழுத்தால் எழுத வேண்டியிருக்கும். அந்த சமயங்களில் எண் மதிப்பை தானாக ஒரு செல்லில் உருவாக்க எக்ஸல் ஷீட்டில் கீழ் கண்டவாறு மேக்ரோ உருவாக்க வேண்டும்.

1.        ஒரு எக்ஸல் டாக்குமெண்ட்டை திறக்கவும்

2.         Fn + ALT+F11 ஒருசேர அழுத்தவும்


 3.         இப்பொழுது தோன்றும் Microsoft visual Basic for Application ல் insert  என்பதை   கிளிக் செய்து அதில் module என்பதை கிளிக் செய்யவும்.
 

4.       அதில் தோன்றும் பெட்டியில் கீழ் கண்ட Program  copy செய்து Paste     செய்யவும்.

Option Explicit

Function SpellNumber(ByVal numIn)
    Dim LSide, RSide, Temp, DecPlace, Count, oNum
    oNum = numIn
    ReDim Place(9) As String
    Place(2) = " Thousand "
    Place(3) = " Million "
    Place(4) = " Billion "
    Place(5) = " Trillion "
    numIn = Trim(Str(numIn)) 'String representation of amount
    ' Edit 2.(0)/Internationalisation
    ' Don't change point sign here as the above assignment preserves the point!
    DecPlace = InStr(numIn, ".") 'Pos of dec place 0 if none
    If DecPlace > 0 Then 'Convert Right & set numIn
        RSide = GetTens(Left(Mid(numIn, DecPlace + 1) & "00", 2))
        numIn = Trim(Left(numIn, DecPlace - 1))
    End If
    RSide = numIn
    Count = 1
    Do While numIn <> ""
        Temp = GetHundreds(Right(numIn, 3))
        If Temp <> "" Then LSide = Temp & Place(Count) & LSide
        If Len(numIn) > 3 Then
            numIn = Left(numIn, Len(numIn) - 3)
        Else
            numIn = ""
        End If
        Count = Count + 1
    Loop

    SpellNumber = LSide
    If InStr(oNum, Application.DecimalSeparator) > 0 Then    ' << Edit 2.(1)
        SpellNumber = SpellNumber & " point " & fractionWords(oNum)
    End If

End Function

Function GetHundreds(ByVal numIn) 'Converts a number from 100-999 into text
    Dim w As String
    If Val(numIn) = 0 Then Exit Function
    numIn = Right("000" & numIn, 3)
    If Mid(numIn, 1, 1) <> "0" Then 'Convert hundreds place
        w = GetDigit(Mid(numIn, 1, 1)) & " Hundred "
    End If
    If Mid(numIn, 2, 1) <> "0" Then 'Convert tens and ones place
        w = w & GetTens(Mid(numIn, 2))
    Else
        w = w & GetDigit(Mid(numIn, 3))
    End If
    GetHundreds = w
End Function

Function GetTens(TensText)  'Converts a number from 10 to 99 into text
    Dim w As String
    w = ""           'Null out the temporary function value
    If Val(Left(TensText, 1)) = 1 Then   'If value between 10-19
        Select Case Val(TensText)
            Case 10: w = "Ten"
            Case 11: w = "Eleven"
            Case 12: w = "Twelve"
            Case 13: w = "Thirteen"
            Case 14: w = "Fourteen"
            Case 15: w = "Fifteen"
            Case 16: w = "Sixteen"
            Case 17: w = "Seventeen"
            Case 18: w = "Eighteen"
            Case 19: w = "Nineteen"
            Case Else
        End Select
    Else      'If value between 20-99..
        Select Case Val(Left(TensText, 1))
            Case 2: w = "Twenty "
            Case 3: w = "Thirty "
            Case 4: w = "Forty "
            Case 5: w = "Fifty "
            Case 6: w = "Sixty "
            Case 7: w = "Seventy "
            Case 8: w = "Eighty "
            Case 9: w = "Ninety "
            Case Else
        End Select
        w = w & GetDigit _
            (Right(TensText, 1))  'Retrieve ones place
    End If
    GetTens = w
End Function

Function GetDigit(Digit) 'Converts a number from 1 to 9 into text
    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

Function fractionWords(n) As String
    Dim fraction As String, x As Long
    fraction = Split(n, Application.DecimalSeparator)(1)   ' << Edit 2.(2)
    For x = 1 To Len(fraction)
        If fractionWords <> "" Then fractionWords = fractionWords & " "
        fractionWords = fractionWords & GetDigit(Mid(fraction, x, 1))
    Next x
End Function

  

5. பிறகு Microsoft visual Basic for Application  close செய்து எக்ஸல் ஷீட்டிற்கு  சென்று 
கீழ்கண்ட Formula மூலம் எண்ணை   வாக்கியத்தில்  பெறலாம்.
6.       A4 செல்லில் இருக்கும்  எண்ணை வாக்கியத்தில் மாற்ற  =SpellNumber(A4)   என்ற FORMULA வை பயன்படுத்தலாம்.
7.        இவ்வாறு மேக்ரோ இணைக்கப்பட எக்ஸல் ஷீட்டை சேவ் செய்யும்  பொழுது கீழ்கண்ட டயலாக் பாக்ஸ் தோன்றும்.

 
அப்பொழுது NO என்று கொடுத்து SAVE AS TYPEல்
Excel Macro-Enabled workbook என்பதை தேர்ந்தெடுத்து சேவ் செய்யவும்.
 

 

Author : tipsdocs // 12:01 AM

1 comments:

  1. Some on-line casinos have excessive wagering necessities, while others don’t have any in any respect. No-deposit bonuses like cashback promotions, weekly bonus spins, and membership rewards provide on-line casino players with tons of opportunities to earn big cash. Withdrawal speeds vary, particularly for casino websites providing gameplay in a 1xbet korea number of} international locations.

    ReplyDelete

 
Powered by Blogger.