untested but replace all of your form code by this
Private Sub CBOCancel_Click()
Unload Me
End Sub
Private Sub CBOClear_Click()
Call UserForm_Initialize
End Sub
Private Sub CBOSave_Click()
Dim RowCount As Long
Dim lCol As Long
'Validasi Data
If CBOJenis.Value = "" Then
CBOJenis.SetFocus
MsgBox "Jenisnya dipilih dong!", vbExclamation, "Data Entry Jenis"
Exit Sub
End If
If CBOTipe.Value = "" Then
CBOTipe.SetFocus
MsgBox "Tipenya dipilih dong", vbExclamation, "Data Entry Tipe"
Exit Sub
End If
If TXTDesk.Value = "" Then
TXTDesk.SetFocus
MsgBox "Deskripsi nya apa?", vbExclamation, "Data Entry Deskripsi"
Exit Sub
End If
If CBOBulan.Value = "" Then
CBOBulan.SetFocus
MsgBox "Bulannya dipilih dong", vbExclamation, "Data Entry Bulan"
Exit Sub
End If
If TXTJumlah.Value = "" Then
TXTJumlah.SetFocus
MsgBox "Jumlahnya diisi dong", vbExclamation, "Data Entry Jumlah"
Exit Sub
End If
If Not IsNumeric(TXTJumlah.Value) = "" Then
TXTJumlah.SetFocus
MsgBox "Isi nya pake Angka ya!", vbExclamation, "Data Entry Jumlah"
Exit Sub
End If
'Input data ke worksheet :p
With Worksheets("EXPENSES")
If Len(.Range("A3").Value) > 0 Then
RowCount = .Range("A2").End(xlDown).Row + 1
Else
RowCount = 3
End If
.Cells(RowCount, "A").Resize(1, 3).Value = Array(CBOJenis.Value, CBOTipe.Value, TXTBOXDesk.Value)
' listindex starts at 0, output column starts in column 4/D so add index to 4 to get correct column for month
lCol = 4 + CBOBulan.ListIndex
.Cells(RowCount, lCol).Value = TXTBOXJumlah.Value
End With
End Sub
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Set ws = Worksheets("LookupLists")
Me.CBOBulan.List = ws.Range("BulanList").Resize(, 2).Value
Me.CBOJenis.List = ws.Range("JenisList").Resize(, 2).Value
Me.CBOTipe.List = ws.Range("TipeList").Resize(, 2).Value
TXTBOXDesk.Value = ""
TXTBOXJumlah.Value = ""
CBOJenis.SetFocus
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Nutup nya pencet Cancel ya!"
End If
End Sub
Bookmarks