100% found this document useful (1 vote)
29 views2 pages

Coding

This code defines a subroutine called TambahData that adds employee data to a spreadsheet. It first checks that all required employee fields are populated. If valid, it copies an employee image file, then copies the employee data from input ranges to the next row in a data range. It saves the workbook and clears the input ranges upon successful addition of an employee record.

Uploaded by

Gesa Lauwoie
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
100% found this document useful (1 vote)
29 views2 pages

Coding

This code defines a subroutine called TambahData that adds employee data to a spreadsheet. It first checks that all required employee fields are populated. If valid, it copies an employee image file, then copies the employee data from input ranges to the next row in a data range. It saves the workbook and clears the input ranges upon successful addition of an employee record.

Uploaded by

Gesa Lauwoie
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_Contract").Value = "" _

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

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

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

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

Or Sheet1.Range("Emp_Birthday").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_Gender").Value

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

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

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

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

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


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

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

DataPegawai.Offset(1, 11).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_Gender").Value = ""

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

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

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

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

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

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

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

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

Sheet1.Image1.Picture = Nothing

ThisWorkbook.Save

End If

End Sub

You might also like