Private Sub buttonclose_Click()
Unload Me
End Sub
Private Sub buttonnew_Click()
Dim Cancel As Boolean
Dim keyCol As Range
Dim i As Long
Set keyCol = ThisWorkbook.Sheets("Data").Columns(2)
If Me.noinvoice.Value = "" Then
MsgBox "Please enter a name", vbExclamation, "Invoice"
Cancel = True
End If
If Me.Tanggal.Value = "" Then
MsgBox "Please enter a item", vbExclamation, "Invoice"
Cancel = True
End If
If Me.Costumers1.Value = "" Then
MsgBox "Please enter a costumers name", vbExclamation, "Invoice"
Cancel = True
End If
If Me.ttd.Value = "" Then
MsgBox "Please enter a ttd", vbExclamation, "Invoice"
Cancel = True
End If
If Me.initial.Value = "" Then
MsgBox "Please enter a initial", vbExclamation, "Invoice"
Cancel = True
End If
If Cancel = True Then
'Do nothing
Else
For i = 1 To 10
If Me.Controls("item" & i).Text <> vbNullString Then
With keyCol.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).EntireRow
.Columns("M").Value = Me.Controls("item" & i).Text
.Columns("O").Value = Me.Controls("unit" & i).Value
.Columns("L").Value = Me.Controls("type" & i).Text
.Columns("N").Value = Me.Controls("harga" & i).Value
.Columns("Q").Value = disc1.Value / 100
.Columns("Z").Value = Me.PajakCode.Value
.Columns("T") = "10%"
.Columns("B") = noinvoice
.Columns("C").Value = Me.Tanggal.Value
.Columns("D").Value = Costumers1.Value
.Columns("W").Value = Note
.Columns("Y").Value = ttd
.Columns("X").Value = initial
End With
End If
Next i
Range("AA1").Select
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1
Unload Me
End If
End Sub
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Set ws = Worksheets("Costumers")
With noinvoice
.Value = Format(Val(Cells(Rows.Count, "B").End(xlUp)) + 1, "0000") & "/" & Format(Month(Date), "00") & "/BMO" & "/" & Right(Year(Date), 2)
.Enabled = False
End With
Me.Tanggal.Value = Format(Date, "short Date")
Me.initial.Value = Range("LoggedInAs").Value
For Each cCostumers1 In ws.Range("AlamatCostumers")
With Me.Costumers1
.AddItem cCostumers1.Value
.List(.ListCount - 1, 1) = cCostumers1.Offset(0, 4).Value
End With
Next cCostumers1
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the close button!!"
End If
End Sub
Bookmarks