Sunday, 27 March 2011

Functions Spelled Currency In MS. Excel

Function is a function that converts fairly nominal value into letters. This function utilizes the Visual Basic Editor provided by Excel. Function is a function that is somewhat User Defined. To make this function follow the steps as follows:
  1. Right-click on the tab - select View Code or Select menu bar Tools - Macro - Visual Basic Editor, or by pressing Alt + F11 shortcut.

    Functions Spelled Currency In MS. Excel

    Functions Spelled Currency In MS. Excel

    Then it will appear as follows:

    Functions Spelled Currency In MS. Excel
  2. Right-click on the Microsoft Excel Objects choose Insert - Module

    Functions Spelled Currency In MS. Excel

    Muncul Tampilan sebagai berikut:

    Functions Spelled Currency In MS. Excel
  3. Enter the following code in module:

    Option Explicit
    Function EkaDigit(N)
    Dim Teks(0 To 9) As String

    Teks(0) = ""
    Teks(1) = "satu"
    Teks(2) = "dua"
    Teks(3) = "tiga"
    Teks(4) = "empat"
    Teks(5) = "lima"
    Teks(6) = "enam"
    Teks(7) = "tujuh"
    Teks(8) = "delapan"
    Teks(9) = "sembilan"
    EkaDigit = Teks(N)

    End Function

    Function TriDigit(N As Integer) As String
    Dim Teks As String
    Dim Ratus As Integer
    Dim Puluh As Integer
    Dim Satu As Integer

    Teks = Right("000" & Trim(Str(N)), 3)
    Ratus = Val(Mid(Teks, 1, 1))
    Puluh = Val(Mid(Teks, 2, 1))
    Satu = Val(Mid(Teks, 3, 1))

    TriDigit = ""
    Select Case Ratus
    Case Is = 0
    TriDigit = ""
    Case Is = 1
    TriDigit = "seratus "
    Case Is > 1
    TriDigit = EkaDigit(Ratus) & " ratus "
    End Select

    Select Case Puluh
    Case Is = 0
    TriDigit = TriDigit & EkaDigit(Satu)
    Case Is = 1
    If Satu = 0 Then
    TriDigit = TriDigit & "sepuluh"
    ElseIf Satu = 1 Then
    TriDigit = TriDigit & "sebelas"
    Else
    TriDigit = TriDigit & EkaDigit(Satu) _
    & " belas"
    End If
    Case Is > 1
    TriDigit = TriDigit & EkaDigit(Puluh) _
    & " puluh " & EkaDigit(Satu)
    End Select
    End Function

    Function Terbilang(N As Double) As String
    Dim Teks As String
    Dim Triliun As Integer
    Dim Milyar As Integer
    Dim Juta As Integer
    Dim Ribu As Integer
    Dim Satu As Integer

    Teks = Right("000000000000000" & Trim(Str(N)), 15)
    Triliun = Val(Mid(Teks, 1, 3))
    Milyar = Val(Mid(Teks, 4, 3))
    Juta = Val(Mid(Teks, 7, 3))
    Ribu = Val(Mid(Teks, 10, 3))
    Satu = Val(Mid(Teks, 13, 3))
    Terbilang = ""

    If Triliun > 0 Then Terbilang = Terbilang & _
    TriDigit(Triliun) & " triliun "
    If Milyar > 0 Then Terbilang = Terbilang & _
    TriDigit(Milyar) & " milyar "
    If Juta > 0 Then Terbilang = Terbilang & _
    TriDigit(Juta) & " juta "
    If Ribu > 1 Then Terbilang = Terbilang & _
    TriDigit(Ribu) & " ribu "
    If Ribu = 1 Then Terbilang = "Seribu "
    If Satu > 0 Then Terbilang = Terbilang & _
    TriDigit(Satu)
    Terbilang = Terbilang & " rupiah"
    End Function
  4. Close the Visual Basic Editor and Return to Microsoft Excel. Check whether the function is successfully made its way: Click the Insert Function (fx) or on the Menu Bar select Insert - Function

    Functions Spelled Currency In MS. Excel
  5. Use of Functions Spelled:

    Functions Spelled Currency In MS. Excel

No comments:

Post a Comment