Langkah - langkah yang dilakukan
1. Buka microsoft Excel
2. Tekan tombol Alt + F11
3. Setelah masuk menu visual basic klik Insert-->Module
4. Selanjutnya copy paste function dibawah ini:
Function Terbilang(uang As Currency, Optional Sen As Boolean = True, Optional MataUang As String = "Rupiah")
Dim Tingkat(0 To 4) As String
Dim sisa As Currency
Dim u As Currency
Dim ut As Currency
Dim st_sen As String, hasil As String
'inisialisasi variabel
Tingkat(0) = ""
Tingkat(1) = "Ribu"
Tingkat(2) = "Juta"
Tingkat(3) = "Milyar"
Tingkat(4) = "Trilyun"
If uang = 0 Then
Terbilang = "Nol " & MataUang
ElseIf uang < 0 Then
u = Abs(uang)
Terbilang = "Minus " & Terbilang(u, Sen, MataUang)
Else
st_sen = ""
u = Fix(uang)
If Sen Then
sisa = Round((uang - u) * 100)
If sisa > 0 Then
st_sen = " " & Terbilang(sisa, False, "Sen")
End If
End If
MataUang = " " & MataUang
hasil = ""
t = 0
While u > 0
ut = Int(u / 1000)
sisa = u - (ut * 1000)
u = ut
If sisa > 0 Then
If (sisa = 1) And (t = 1) Then
hasil = Trim("Seribu " & hasil)
Else
hasil = Trim(AngkaKeHuruf(sisa) & " " & Tingkat(t) & " " & hasil)
End If
End If
t = (t + 1) Mod 5
Wend
Terbilang = hasil & MataUang & st_sen
End If
End Function
Function AngkaKeHuruf(angka As Currency)
Dim p As Currency
Dim s As Currency
Dim r As Currency
r = Int(angka / 100)
Dim angka2 As Currency
angka2 = angka - (r * 100)
'untuk ratusan
If r = 0 Then
st_r = ""
ElseIf r = 1 Then
st_r = "Seratus"
Else
st_r = AngkaKeHuruf(r) & "ratus"
End If
'untuk puluhan dan satuan
Select Case angka2
Case 0: st_ps = ""
Case 1: st_ps = "Satu"
Case 2: st_ps = "Dua "
Case 3: st_ps = "Tiga "
Case 4: st_ps = "Empat "
Case 5: st_ps = "Lima "
Case 6: st_ps = "Enam "
Case 7: st_ps = "Tujuh "
Case 8: st_ps = "Delapan "
Case 9: st_ps = "Sembilan "
Case 10: st_ps = "Sepuluh "
Case 11: st_ps = "Sebelas "
Case 12 To 19: st_ps = AngkaKeHuruf(angka2 - 10) & "belas"
Case Else
p = Int(angka2 / 10)
s = (angka2 - (p * 10))
If p = 0 Then
st_ps = AngkaKeHuruf(s)
Else
st_ps = AngkaKeHuruf(p) & "puluh" & " " & AngkaKeHuruf(s)
End If
End Select
AngkaKeHuruf = Trim(st_r & " " & st_ps)
End Function
5. Selanjutnya close module, tempatkan rumus tersebut dimana anda akan merubah angka tsb.
Contoh di kolom B1 ketik tanpa tanda kutip "=bilangan(A1)" seperti contoh dibawah ini:
6. Save file dengan extensi .xlsm
Wednesday, 21 May 2014
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment