Menu

Rabu, 25 Oktober 2017

Buat Angsuran pinjaman menurun dengan VBA Excel

Private Sub Ags_AfterUpdate()
If Ags <> "" Then
ListBox1.Clear
Call TampilList
Dim a As Integer
For a = 1 To 12
 With ListBox1
.AddItem
 .List(.ListCount - 1, 0) = a
 .List(.ListCount - 1, 1) = Format(WorksheetFunction.EDate(Now(), (a)), "mmmm yyyy;@")
 .List(.ListCount - 1, 2) = "Rp." & Format(Ags - ((Ags / 12) * (a - 1)), "###,###")
 .List(.ListCount - 1, 3) = "Rp." & Format((Ags - ((Ags / 12) * (a - 1))) * (5 / 100), "###,###")
 .List(.ListCount - 1, 4) = "Rp." & Format(Ags / 12, "###,###")
 .List(.ListCount - 1, 5) = "Rp." & Format(Ags / 12 + (Ags - ((Ags / 12) * (a - 1))) * (5 / 100), "###,###")
 .List(.ListCount - 1, 6) = "Rp." & Format(Ags - ((Ags / 12) * a), "###,###")
  End With
 Next a
 Ags.Value = Format(Ags.Value, "###,###")
 End If
End Sub
Sub TampilList()
With ListBox1
.AddItem
.List(.ListCount - 1, 0) = "Ags." ' Kolom pertama
.List(.ListCount - 1, 1) = "Tanggal" 'Kolom kedua dan seterusnya
.List(.ListCount - 1, 2) = "Saldo"
.List(.ListCount - 1, 3) = "Jasa"
.List(.ListCount - 1, 4) = "Pokok"
.List(.ListCount - 1, 5) = "Jumlah"
.List(.ListCount - 1, 6) = "Saldo"
End With
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
On Error Resume Next
If ListBox1.ListIndex > 0 Then
ListBox1.RemoveItem (ListBox1.ListIndex)
End If
End Sub
Private Sub KELUAR_Click()
TRANSAKSI.TxtPINJ = Format(ANGSURAN.Ags * 1, "#,##0")
Unload Me
End Sub
Private Sub Label36_Click()
ListBox1.Clear
Ags.Value = ""
End Sub