Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Option Explicit

Private Sub Simpan_Click()

Dim irow As Long

Dim ws As Worksheet

Set ws = Worksheets("AGUSTUS22")

'menemukan baris Kosong pada Database""

irow = ws.Cells(Rows.Count, 10) _

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

If WorksheetFunction.CountIf(ws.Range("A4", ws.Cells(irow - 1, 10)), Me.TextBox1.Value) > 0 Then

MsgBox "NAMA SUDAH ADA,SILAHKAN MASUKAN DENGAN NAMA LENGKAP", vbCritical

Exit Sub

End If

'Cek data yang dientri pada textbox1""

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

Me.TextBox1.SetFocus

MsgBox "Silahkan Masukkan Nama"

Exit Sub

End If

'Copy Data ke Database"""

ws.Cells(irow, 1).Value = Me.TextBox1.Value

ws.Cells(irow, 2).Value = Me.TextBox2.Value

ws.Cells(irow, 3).Value = Me.TextBox3.Value

ws.Cells(irow, 4).Value = Me.TextBox4.Value

ws.Cells(irow, 5).Value = Me.TextBox5.Value


ws.Cells(irow, 6).Value = Me.TextBox6.Value

ws.Cells(irow, 7).Value = Me.TextBox7.Value

ws.Cells(irow, 8).Value = Me.TextBox8.Value

ws.Cells(irow, 9).Value = Me.TextBox9.Value

ws.Cells(irow, 10).Value = Me.TextBox10.Value

Application.Speech.Speak "konak am ju"

MsgBox "BERHASIL MASUK TABEL"

Call Clean

End Sub

Private Sub UserForm_Activate()

Dim ws As Worksheet

Set ws = Worksheets("AGUSTUS22")

On Error Resume Next

End Sub

Sub Clean()

Dim AdaText

For Each AdaText In Me.Controls

If TypeOf AdaText Is MSForms.TextBox Then

AdaText.Text = ""

End If

Next AdaText
Me.TextBox1.SetFocus

End Sub

Private Sub UserForm_Click()

End Sub

You might also like