0% found this document useful (0 votes)
18 views2 pages

Sub TambahData (-WPS Office

This document describes a procedure for adding employee data. It defines variables to store the employee ID and last row of data. It checks for empty or duplicate fields, then copies an image file and inserts the employee values into the data range if valid. On success, it clears the input fields and saves the workbook.

Uploaded by

sherina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Sub TambahData (-WPS Office

This document describes a procedure for adding employee data. It defines variables to store the employee ID and last row of data. It checks for empty or duplicate fields, then copies an image file and inserts the employee values into the data range if valid. On success, it clears the input fields and saves the workbook.

Uploaded by

sherina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Sub TambahData()

Dim DataPegawai As Object

Dim GBARANG As String

GBARANG = Sheet1.Range("Emp_Id").Value

Set DataPegawai = Sheet1.Range("C100000").End(xlUp)

If Sheet1.Range("Emp_Id").Value = "" _

Or Sheet1.Range("D4").Value = 1 _

Or Sheet1.Range("Emp_Name").Value = "" _

Or Sheet1.Range("Emp_Job").Value = "" _

Or Sheet1.Range("Emp_Dep").Value = "" _

Or Sheet1.Range("Emp_Hire").Value = "" _

Or Sheet1.Range("Emp_Phone").Value = "" _

Or Sheet1.Range("Emp_Email").Value = "" _

Or Sheet1.Range("Emp_BirthD").Value = "" _

Or Sheet1.Range("Emp_Image").Value = "" Then

Call MsgBox("Data pegawai harus lengkap atau data Id Employee telah digunakan", vbInformation,
"Data Pegawai")

Else

FileCopy ErwinG, ThisWorkbook.Path & "\" & GBARANG & ".jpg"

DataPegawai.Offset(1, 0).Value = Sheet1.Range("Emp_Id").Value

DataPegawai.Offset(1, 1).Value = Sheet1.Range("Emp_Name").Value

DataPegawai.Offset(1, 2).Value = Sheet1.Range("Emp_Job").Value

DataPegawai.Offset(1, 3).Value = Sheet1.Range("Emp_Dep").Value

DataPegawai.Offset(1, 4).Value = Sheet1.Range("Emp_Hire").Value

DataPegawai.Offset(1, 5).Value = Sheet1.Range("Emp_Phone").Value


DataPegawai.Offset(1, 6).Value = Sheet1.Range("Emp_Email").Value

DataPegawai.Offset(1, 7).Value = Sheet1.Range("Emp_BirthD").Value

DataPegawai.Offset(1, 8).Value = Sheet1.Range("Emp_Image").Value

Call MsgBox("Data pegawai berhasil ditambah", vbInformation, "Data Pegawai")

Sheet1.Range("Emp_Id").Value = ""

Sheet1.Range("Emp_Name").Value = ""

Sheet1.Range("Emp_Job").Value = ""

Sheet1.Range("Emp_Dep").Value = ""

Sheet1.Range("Emp_Hire").Value = ""

Sheet1.Range("Emp_Phone").Value = ""

Sheet1.Range("Emp_Email").Value = ""

Sheet1.Range("Emp_BirthD").Value = ""

Sheet1.Range("Emp_Image").Value = ""

Sheet1.Image1.Picture = Nothing

ThisWorkbook.Save

End If

End Sub

You might also like