Membuat Angka Terbilang pada EXEL

  1. Buka Microsoft Excel.
  2. Tekan Alt + F11 untuk membuka VBA Editor, atau klik menu Tools -> Macro -> Visual Basic Editor. (Contoh pada Gambar 2)
Run Visual Basic

Run Visual Basic

3. Di Visual Basic Editor, klik menu Insert -> Module. (contoh pada Gambar 3)

Insert Module

Insert Module

4. Lalu copy-paste script ini ke bidang kerjanya (Anda Blok semua, copy (ctrl+c) lalu Paste (ctrl+v):

Public Function TERBILANG(x As Double) As String
Dim tampung As Double
Dim teks As String
Dim bagian As String
Dim i As Integer
Dim tanda As Boolean
Dim letak(5)

letak(1) = "RIBU "
letak(2) = "JUTA "
letak(3) = "MILYAR "
letak(4) = "TRILYUN "

If (x < 0) Then
TERBILANG = ""
Exit Function
End If

If (x = 0) Then
TERBILANG = "NOL"
Exit Function
End If

If (x < 2000) Then
tanda = True
End If

teks = ""
If (x >= 1E+15) Then
TERBILANG = "NILAI TERLALU BESAR"
Exit Function
End If

For i = 4 To 1 Step -1
tampung = Int(x / (10 ^ (3 * i)))
If (tampung > 0) Then
bagian = ratusan(tampung, tanda)
teks = teks & bagian & letak(i)
End If
x = x - tampung * (10 ^ (3 * i))
Next
teks = teks & ratusan(x, False)
TERBILANG = teks & " RUPIAH"
End Function

Function ratusan(ByVal y As Double, ByVal flag As Boolean) As String
Dim tmp As Double
Dim bilang As String
Dim bag As String
Dim j As Integer
Dim angka(9)
angka(1) = "SE"
angka(2) = "DUA "
angka(3) = "TIGA "
angka(4) = "EMPAT "
angka(5) = "LIMA "
angka(6) = "ENAM "
angka(7) = "TUJUH "
angka(8) = "DELAPAN "
angka(9) = "SEMBILAN "
Dim posisi(2)
posisi(1) = "PULUH "
posisi(2) = "RATUS "
bilang = ""
For j = 2 To 1 Step -1
tmp = Int(y / (10 ^ j))
If (tmp > 0) Then
bag = angka(tmp)
If (j = 1 And tmp = 1) Then
y = y - tmp * 10 ^ j
If (y >= 1) Then
posisi(j) = "BELAS "
Else
angka(y) = "SE"
End If
bilang = bilang & angka(y) & posisi(j)
ratusan = bilang
Exit Function
Else
bilang = bilang & bag & posisi(j)
End If
End If
y = y - tmp * 10 ^ j
Next
If (flag = False) Then
angka(1) = "SATU "
End If
bilang = bilang & angka(y)
ratusan = bilang
End Function





Ini contoh gambar screenshot-nya:
Copy Paste The script

Copy Paste The script

5. Setelah di paste,
Coba cek script ini dengan klik menu Debug -> Compile VBA Project,
jika tidak keluar kotak peringatan apapun biasanya script anda sudah beres.

6. Tutup jendela Visual Basic Editor anda.

posted under |

Tidak ada komentar:

Posting Komentar

Posting Lebih Baru Posting Lama Beranda

TUTORIAL TARI REMO

https://youtu.be/8w-dDqK4IKQ?list=PL1eCE4RsRsOic8j_sAfRldg1mqq74LrE

Followers


Recent Comments