Headlines News :
Home » » CARA BUAT RUMUS TERBILANG KELUAR SECARA OTOMATIS DI EXCEL 2007/2010

CARA BUAT RUMUS TERBILANG KELUAR SECARA OTOMATIS DI EXCEL 2007/2010

Written By Regina Kim on Senin, 22 Juli 2013 | 00.55


To the poin Langsung ke masalahnya aja ya :

1. Copy paste kode dibawah ini kedalam notepad kamu (ada yang pakai rupiah ada juga yang tidak pakai rupiah, terserah kebutuhan)

Ingin Kode Terbilang dengan akhiran rupiah copas kode dibawah ini : 

Attribute VB_Name = "Module1"
Option Explicit

Function Terbilang(ByVal MyNumber)
Dim Rupiah, Sen, Temp
Dim Des, Desimal, Count, Tmp
Dim IsNeg

ReDim Place(9) As String
Place(2) = "RIBU "
Place(3) = "JUTA "
Place(4) = "MILYAR "
Place(5) = "TRILYUN "

'Ubah angka menjadi string
MyNumber = Round(MyNumber, 2)
MyNumber = Trim(Str(MyNumber))

'Cek bilangan negatif
If Mid(MyNumber, 1, 1) = "-" Then
MyNumber = Right(MyNumber, Len(MyNumber) - 1)
IsNeg = True
End If

'Posisi desimal, 0 jika bil. bulat
Desimal = InStr(MyNumber, ".")
'Pembulatan sen, dua angka di belakang koma
Des = Mid(MyNumber, Desimal + 2)
If Desimal > 0 Then
Tmp = Left(Mid(MyNumber, Desimal + 1) & "00", 2)
If Left(Tmp, 1) = "0" Then
Tmp = Mid(Tmp, 2)
Sen = Satuan(Tmp)
Else
Sen = Puluhan(Tmp)
End If
MyNumber = Trim(Left(MyNumber, Desimal - 1))
End If

Count = 1
Do While MyNumber <> ""
Temp = Ratusan(Right(MyNumber, 3), Count)
If Temp <> "" Then Rupiah = Temp & Place(Count) & Rupiah
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop

Select Case Rupiah
Case ""
Rupiah = "NOL RUPIAH"
Case Else
Rupiah = Rupiah & "RUPIAH"
End Select

Select Case Sen
Case ""
Sen = ""
Case Else
Sen = " DAN " & Sen & "SEN"
End Select

If IsNeg = True Then
Terbilang = "MINUS " & Rupiah & Sen
Else
Terbilang = Rupiah & Sen
End If

End Function


' Mengubah angka 100-999 menjadi teks *
Function Ratusan(ByVal MyNumber, Count)
Dim Result As String
Dim Tmp

If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)

'Mengubah seribu
If MyNumber = "001" And Count = 2 Then
Ratusan = "SE"
Exit Function
End If

'Mengubah ratusan
If Mid(MyNumber, 1, 1) <> "0" Then
If Mid(MyNumber, 1, 1) = "1" Then
Result = "SERATUS "
Else
Result = Satuan(Mid(MyNumber, 1, 1)) & "RATUS "
End If
End If

'Mengubah puluhan dan satuan
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & Puluhan(Mid(MyNumber, 2))
Else
Result = Result & Satuan(Mid(MyNumber, 3))
End If

Ratusan = Result

End Function


'*******************
' Mengubah puluhan *
Function Puluhan(TeksPuluhan)
Dim Result As String

Result = ""
' nilai antara 10-19
If Val(Left(TeksPuluhan, 1)) = 1 Then
Select Case Val(TeksPuluhan)
Case 10: Result = "SEPULUH "
Case 11: Result = "SEBELAS "
Case Else
Result = Satuan(Mid(TeksPuluhan, 2)) & "BELAS "
End Select
' nilai antara 20-99
Else
Result = Satuan(Mid(TeksPuluhan, 1, 1)) _
& "PULUH "
Result = Result & Satuan(Right(TeksPuluhan, 1))
'satuan
End If
Puluhan = Result
End Function


'********************************
' Mengubah satuan menjadi teks. *
Function Satuan(Digit)
Select Case Val(Digit)
Case 1: Satuan = "SATU "
Case 2: Satuan = "DUA "
Case 3: Satuan = "TIGA "
Case 4: Satuan = "EMPAT "
Case 5: Satuan = "LIMA "
Case 6: Satuan = "ENAM "
Case 7: Satuan = "TUJUH "
Case 8: Satuan = "DELAPAN "
Case 9: Satuan = "SEMBILAN "
Case Else: Satuan = ""
End Select
End Function

Atau Kode terbilang tanpa akhiran rupiah copas kode dibawah ini :

Function Terbilang(ByVal MyNumber)
Dim Rupiah, Sen, Temp
Dim Des, Desimal, Count, Tmp
Dim IsNeg

ReDim Place(9) As String
Place(2) = "ribu "
Place(3) = "juta "
Place(4) = "milyar "
Place(5) = "trilyun "

'Ubah angka menjadi string
MyNumber = Round(MyNumber, 2)
MyNumber = Trim(Str(MyNumber))

'Cek bilangan negatif
If Mid(MyNumber, 1, 1) = "-" Then
MyNumber = Right(MyNumber, Len(MyNumber) - 1)
IsNeg = True
End If

'Posisi desimal, 0 jika bil. bulat
Desimal = InStr(MyNumber, ".")
'Pembulatan sen, dua angka di belakang koma
Des = Mid(MyNumber, Desimal + 2)
If Desimal > 0 Then
Tmp = Left(Mid(MyNumber, Desimal + 1) & "00", 2)
If Left(Tmp, 1) = "0" Then
Tmp = Mid(Tmp, 2)
Sen = Satuan(Tmp)
Else
Sen = Puluhan(Tmp)
End If
MyNumber = Trim(Left(MyNumber, Desimal - 1))
End If

Count = 1
Do While MyNumber <> ""
Temp = Ratusan(Right(MyNumber, 3), Count)
If Temp <> "" Then Rupiah = Temp & Place(Count) & Rupiah
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop

Select Case Rupiah
Case ""
Rupiah = "nol rupiah"
Case Else
Rupiah = Rupiah & "rupiah"
End Select

Select Case Sen
Case ""
Sen = ""
Case Else
Sen = " dan " & Sen & "sen"
End Select

If IsNeg = True Then
Terbilang = "minus " & Rupiah & Sen
Else
Terbilang = Rupiah & Sen
End If

End Function


'**************************************
' Mengubah angka 100-999 menjadi teks *
'**************************************
Function Ratusan(ByVal MyNumber, Count)
Dim Result As String
Dim Tmp

If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)

'Mengubah seribu
If MyNumber = "001" And Count = 2 Then
Ratusan = "se"
Exit Function
End If

'Mengubah ratusan
If Mid(MyNumber, 1, 1) <> "0" Then
If Mid(MyNumber, 1, 1) = "1" Then
Result = "seratus "
Else
Result = Satuan(Mid(MyNumber, 1, 1)) & "ratus "
End If
End If

'Mengubah puluhan dan satuan
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & Puluhan(Mid(MyNumber, 2))
Else
Result = Result & Satuan(Mid(MyNumber, 3))
End If

Ratusan = Result

End Function


'*******************
' Mengubah puluhan *
'*******************
Function Puluhan(TeksPuluhan)
Dim Result As String

Result = ""
' nilai antara 10-19
If Val(Left(TeksPuluhan, 1)) = 1 Then
Select Case Val(TeksPuluhan)
Case 10: Result = "sepuluh "
Case 11: Result = "sebelas "
Case Else
Result = Satuan(Mid(TeksPuluhan, 2)) & "belas "
End Select
' nilai antara 20-99
Else
Result = Satuan(Mid(TeksPuluhan, 1, 1)) _
& "puluh "
Result = Result & Satuan(Right(TeksPuluhan, 1))
'satuan
End If
Puluhan = Result
End Function


'********************************
' Mengubah satuan menjadi teks. *
'********************************
Function Satuan(Digit)
Select Case Val(Digit)
Case 1: Satuan = "satu "
Case 2: Satuan = "dua "
Case 3: Satuan = "tiga "
Case 4: Satuan = "empat "
Case 5: Satuan = "lima "
Case 6: Satuan = "enam "
Case 7: Satuan = "tujuh "
Case 8: Satuan = "delapan "
Case 9: Satuan = "sembilan "
Case Else: Satuan = ""
End Select
End Function

2. Lalu Save As dengan akhiran "terbilang.xlam" dan taruh terserah anda, contoh c:/My Documents
3. Kemudian buka excel 2007/2010
4. ke menu File lalu cari menu Excel Option (lihat gambar)


5.Pilih tabs "Add-Ins", lalu "Go…".


6. Muncul kotak berikut tekan pada tombol "Browse"


7. Cari file yang anda simpan tadi (misal di c:/My Documents/terbilang.xlam)


8. Klik tombol "Ok" lalu akan muncul kotak berikut :


9. Klik Ok lagi untuk menyeselaikan proses pemasangan Add-Ins
Sekarang kita check apakah fungsi tersebut berfungsi. Untuk memakainya anda perlu mengetahui formulanya. Misal angka yang hendak anda buatkan terbilangnya ada di cell "A1", maka formulanya adalah sebagai berikut :
=terbilang(A1,4,"Rupiah.")


10. Selesai.

Semoga berguna ya



Share this article :

1 komentar:

blog misteri mengatakan...

bermanfaat banget, terima kasih sudah dishare

Diberdayakan oleh Blogger.

Google Translate

 
Support : Creating Website | Johny Template | Mas Template
Proudly powered by Blogger
Copyright © 2011. Be Smart with science - All Rights Reserved
Template Design by Creating Website Published by Mas Template