Coba ini pak.. (ini jg dapat dari Inet)

Public Function bilangan(x As Double) As String
    ANGKA = Array("", "Se", "Dua", "Tiga", "Empat", "Lima", "Enam", "Tujuh", 
"Delapan", "Sembilan", "Sepuluh")
    Level = Array("Triliun ", "Miliar ", "Juta ", "Ribu ", "")
    MAXDIGIT = Right("000000000000000" & Abs(Round(x, 0)), 15)
        For i = 0 To 4
            TEMPRP = ""
            If Mid(MAXDIGIT, 1 + (3 * i), 1) > 0 Then TEMPRP = 
ANGKA(Mid(MAXDIGIT, 1 + (3 * i), 1)) & "ratus "
            If Mid(MAXDIGIT, 2 + (3 * i), 2) < 11 Then
                TEMPRP = TEMPRP & ANGKA(Mid(MAXDIGIT, 2 + (3 * i), 2))
            ElseIf Mid(MAXDIGIT, 2 + (3 * i), 2) < 20 Then
                TEMPRP = TEMPRP & ANGKA(Mid(MAXDIGIT, 3 + (3 * i), 1)) & "belas 
"
            Else
                TEMPRP = TEMPRP & ANGKA(Mid(MAXDIGIT, 2 + (3 * i), 1)) & "puluh 
" & ANGKA(Mid(MAXDIGIT, 3 + (3 * i), 1))
            End If
            If Right(TEMPRP, 1) <> " " Then TEMPRP = TEMPRP & " "
BERILEVEL:
            If TEMPRP <> " " Then TEMPRP = TEMPRP & Level(i)
            If TEMPRP = "Se Ribu " Then TEMPRP = "Seribu "
            If TEMPRP <> " " Then bilangan = 
Application.WorksheetFunction.Substitute(bilangan & TEMPRP, "Se ", "Satu ")
        Next i
        If Abs(Round(x, 0)) = 0 Then bilangan = "Nol "
        If x < 0 Then bilangan = "Minus " & bilangan
End Function




Wassalam


~ Bagus ~






  ----- Original Message -----
  From: Edhie Wibowo [email protected] [XL-mania]
  To: [email protected]
  Sent: Monday, August 25, 2014 10:45 AM
  Subject: ]] XL-mania [[ Menulis bilangan utk uang (Rupiah)





  Dear temans,
  saya mau tanya nih, ttg macro penulisan bilangan utk uang (rupiah),
  dapet dari google dalam dollar, kemudian saya modifikasi jadi rupiah.
  Sejauh ini sih macronya berhasil dgn baik, hanya ketika ada angka 100,
  tidak bisa membacanya "seratus" tapi satu ratus, juga 10, tidak dibaca
  "sepuluh", tapi satu puluh. Gimana spy bisa terbaca cara Indonesia?


  Mohon solusinya dari para master. Terima kasih banyak.


  -------------------------------------------
  Option Explicit
  'Main Function
  Function SpellNumber(ByVal MyNumber)
  Dim Dollars, Cents, Temp
  Dim DecimalPlace, Count
  ReDim Place(9) As String
  Place(2) = " ribu "
  Place(3) = " juta "
  Place(4) = " milyar "
  Place(5) = " trilyun "
  ' String representation of amount.
  MyNumber = Trim(Str(MyNumber))
  ' Position of decimal place 0 if none.
  DecimalPlace = InStr(MyNumber, ".")
  ' Convert cents and set MyNumber to dollar amount.
  If DecimalPlace > 0 Then
  Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
  "00", 2))
  MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
  End If
  Count = 1
  Do While MyNumber <> ""
  Temp = GetHundreds(Right(MyNumber, 3))
  If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
  If Len(MyNumber) > 3 Then
  MyNumber = Left(MyNumber, Len(MyNumber) - 3)
  Else
  MyNumber = ""

  End If
  Count = Count + 1
  Loop
  Select Case Dollars
  Case ""
  Dollars = "Tidak ada uang"
  Case "One"
  Dollars = "satu rupiah"
  Case Else
  Dollars = Dollars & " rupiah"
  End Select
  Select Case Cents
  Case ""
  Cents = " "
  Case "One"
  Cents = " dan satu sen"
  Case Else

  Cents = " and " & Cents & " sen"
  End Select
  SpellNumber = Dollars & Cents
  End Function


  ' Converts a number from 100-999 into text
  Function GetHundreds(ByVal MyNumber)
  Dim Result As String
  If Val(MyNumber) = 0 Then Exit Function
  MyNumber = Right("000" & MyNumber, 3)
  ' Convert the hundreds place.
  If Mid(MyNumber, 1, 1) <> "0" Then
  Result = GetDigit(Mid(MyNumber, 1, 1)) & " ratus "
  End If
  ' Convert the tens and ones place.
  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


  ' Converts a number from 10 to 99 into text.
  Function GetTens(TensText)
  Dim Result As String
  Result = "" ' Null out the temporary function value.
  If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19...
  Select Case Val(TensText)
  Case 10: Result = "sepuluh"
  Case 11: Result = "sebelas"
  Case 12: Result = "dua belas"
  Case 13: Result = "tiga belas"
  Case 14: Result = "empat belas"
  Case 15: Result = "lima belas"
  Case 16: Result = "enam belas"
  Case 17: Result = "tujuh belas"
  Case 18: Result = "Delapan Belas"
  Case 19: Result = "Sembilan Belas"
  Case Else
  End Select
  Else ' If value between 20-99...
  Select Case Val(Left(TensText, 1))
  Case 2: Result = "dua puluh "
  Case 3: Result = "tiga puluh "
  Case 4: Result = "empat puluh "
  Case 5: Result = "lima puluh "
  Case 6: Result = "enam puluh "
  Case 7: Result = "tujuh puluh "
  Case 8: Result = "delapan puluh "
  Case 9: Result = "sembilan puluh "
  Case Else
  End Select
  Result = Result & GetDigit _
  (Right(TensText, 1)) ' Retrieve ones place.
  End If
  GetTens = Result
  End Function


  ' Converts a number from 1 to 9 into text.
  Function GetDigit(Digit)
  Select Case Val(Digit)
  Case 1: GetDigit = "satu"
  Case 2: GetDigit = "dua"
  Case 3: GetDigit = "tiga"
  Case 4: GetDigit = "empat"
  Case 5: GetDigit = "lima"
  Case 6: GetDigit = "enam"
  Case 7: GetDigit = "tujuh"
  Case 8: GetDigit = "delapan"
  Case 9: GetDigit = "sembilan"
  Case Else: GetDigit = ""
  End Select
  End Function


  ----------------------------------------------------------


  --
  Jabat hangat,
  Edhie Wibowo



  "Vision Shows the Way, Passion Sustains the Journey"




  

Kirim email ke