You are on page 1of 2

Private Sub CMDSIMPAN_Click()

Dim Kolom As Long

Dim Lembar As Worksheet

Set Lembar = Worksheets("PENJUALAN")

Kolom = Lembar.Cells(Rows.Count, 1) _

.End(xlUp).Offset(1, 0).Row

'ngecek kolom kosong

If Trim(Me.TextTANGGAL.Value) = "" Then

Me.TextTANGGAL.SetFocus

MsgBox "No Tidak Boleh Kosong"

Exit Sub

End If

'fungsi memasukkan data ke cells

Lembar.Cells(Kolom, 1).Value = Me.TextTANGGAL

Lembar.Cells(Kolom, 2).Value = Me.TextNAMABARANG

Lembar.Cells(Kolom, 3).Value = Me.TextKODEBARANG

Lembar.Cells(Kolom, 4).Value = Me.TextHARGA

'HAPUS DATA

Me.TextTANGGAL.Value = ""

Me.TextNAMABARANG.Value = ""

Me.TextKODEBARANG.Value = ""

Me.TextHARGA.Value = ""

End Sub
Private Sub CMDKELUAR_Click()

Unload Me

End Sub

Private Sub UserForm_QueryClose(cancel As Integer, _

CloseMode As Integer)

If CloseMode = vbFormControlMenu Then

cancel = True

MsgBox "Gunakan Tombol KELUAR"

End If

End Sub

End Sub

You might also like