0% found this document useful (0 votes)
6 views3 pages

Coding Part 1

The document contains code for several modules and forms related to managing institution data in Excel. It includes code for opening settings and institution forms, resetting search fields, searching, sorting institutions, and adding, editing, and deleting institution records.

Uploaded by

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

Coding Part 1

The document contains code for several modules and forms related to managing institution data in Excel. It includes code for opening settings and institution forms, resetting search fields, searching, sorting institutions, and adding, editing, and deleting institution records.

Uploaded by

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

----------------------------------------

CODING MODUL UTAMA


----------------------------------------
Sub BukaPengaturan()
FORMPENGATURAN.Show
End Sub
Sub BukaInstansi()
FORMINSTANSI.Show
End Sub
Sub RESET()
Application.ScreenUpdating = False
On Error Resume Next
Sheet1.CARIINSTANSI.Value = ""
Sheet2.Select
Sheet1.TABELINSTANSI.ListFillRange = "INSTANSI!A5:E" & Range("E" &
Rows.Count).End(xlUp).Row
Sheet1.Select
End Sub
Sub Hasilcari()
Application.ScreenUpdating = False
On Error Resume Next
Sheet2.Select
Sheet1.TABELINSTANSI.ListFillRange = ""
Sheet1.TABELINSTANSI.ListFillRange = "INSTANSI!I5:M" & Range("M" &
Rows.Count).End(xlUp).Row
Sheet1.Select

End Sub

---------------------------------------
CODING MODUL URUT
---------------------------------------
Sub UrutInstansi()
Application.ScreenUpdating = False
Sheet2.Select
Sheet2.Range("B4:E500000").Sort KEY1:=Range("B4"), Order1:=xlAscending,
Header:=xlYes
Sheet1.Select
End Sub

------------------------------------------
CODING FORM PENGATURAN
------------------------------------------
Private Sub ATUR_Click()
If Me.NAMAINJSTANSI.Value = "" _
Or Me.Alamat.Value = "" _
Or Me.TELPON.Value = "" Then
Call MsgBox("Harap isi data Instansi dengan Lengkap", vbInformation, "Data
Instansi")
Else
Sheet3.Range("A5").Value = Me.NAMAINJSTANSI.Value
Sheet3.Range("B5").Value = Me.Alamat.Value
Sheet3.Range("C5").Value = Me.TELPON.Value
Me.NAMAINJSTANSI.Enabled = False
Me.Alamat.Enabled = False
Me.TELPON.Enabled = False
Call MsgBox("Pengaturan Instansi selesai dilakukan", vbInformation, "Data
Instansi")
End If
End Sub

Private Sub RESET_Click()


Me.NAMAINJSTANSI.Enabled = True
Me.Alamat.Enabled = True
Me.TELPON.Enabled = True

End Sub
Private Sub UserForm_Initialize()
Me.NAMAINJSTANSI.Value = Sheet3.Range("A5").Value
Me.Alamat.Value = Sheet3.Range("B5").Value
Me.TELPON.Value = Sheet3.Range("C5").Value
Me.NAMAINJSTANSI.Enabled = False
Me.Alamat.Enabled = False
Me.TELPON.Enabled = False
End Sub

--------------------------------------
CODING FORM INSTANSI
--------------------------------------
Private Sub HAPUS_Click()
Application.ScreenUpdating = False
'Menentukan Object acuan data yang akan dihapus
If Me.NAMAINJSTANSI.Value = "" Then
Call MsgBox("Pilih data pada tabel data", vbInformation, "Hapus Data")
Else
'Membuat pesan konfirmasi hapus data
Select Case MsgBox("Anda akan menghapus data" _
& vbCrLf & "Apakah anda yakin?" _
, vbYesNo Or vbQuestion Or vbDefaultButton1, "Hapus data")
Case vbNo
Exit Sub
Case vbYes
End Select
'Menentukan tempat hapus data, menghapus data dan membersihkan form
Set Hapusdata = Sheet2.Range("B5:B500000").Find(What:=Me.NAMAINJSTANSI.Value,
LookIn:=xlValues)
Hapusdata.Offset(0, 0).ClearContents
Hapusdata.Offset(0, 1).ClearContents
Hapusdata.Offset(0, 2).ClearContents
Hapusdata.Offset(0, 3).ClearContents
Hapusdata.Offset(0, 4).ClearContents
Call MsgBox("Data berhasil dihapus", vbInformation, "Hapus Data")
Me.NAMAINJSTANSI.Value = ""
Me.Alamat.Value = ""
Me.TELPON.Value = ""
Me.EMAIL.Value = ""
Call UrutInstansi
End If

End Sub

Private Sub TAMBAH_Click()


Application.ScreenUpdating = False
Dim DataInstansi As Object
Set DataInstansi = Sheet2.Range("B100").End(xlUp)

If Me.NAMAINJSTANSI.Value = "" _
Or Me.Alamat.Value = "" _
Or Me.TELPON.Value = "" _
Or Me.EMAIL.Value = "" Then
Call MsgBox("harap isi lengkap data instansi", vbInformation, "Data Instansi")
Else
DataInstansi.Offset(1, 0).Value = Me.NAMAINJSTANSI.Value
DataInstansi.Offset(1, 1).Value = Me.Alamat.Value
DataInstansi.Offset(1, 2).Value = Me.TELPON.Value
DataInstansi.Offset(1, 3).Value = Me.EMAIL.Value
On Error Resume Next
Sheet2.Select
Sheet1.TABELINSTANSI.ListFillRange = "INSTANSI!A5:E" & Range("E" &
Rows.Count).End(xlUp).Row
Sheet1.Select
Call MsgBox("Data berhasil di tambah", vbInformation, "Data Instansi")

Me.NAMAINJSTANSI.Value = ""
Me.Alamat.Value = ""
Me.TELPON.Value = ""
Me.EMAIL.Value = ""
End If
End Sub

Private Sub UBAH_Click()


Application.ScreenUpdating = False
Dim BARIS, SUMBERUBAH As String
If Me.NAMAINJSTANSI.Text = "" Then
Call MsgBox("Pilih data terlebih dahulu", vbInformation, "Pilih Data")
Else
Sheet2.Select
SUMBERUBAH = Sheets("INSTANSI").Cells(Rows.Count, "B").End(xlUp).Row
Sheets("INSTANSI").Range("B5:B" &
SUMBERUBAH).Find(What:=Sheet1.TABELINSTANSI.Column(1), LookIn:=xlValues,
LookAt:=xlWhole).Activate
BARIS = ActiveCell.Row

Cells(BARIS, 2) = Me.NAMAINJSTANSI.Value
Cells(BARIS, 3) = Me.Alamat.Value
Cells(BARIS, 4) = Me.TELPON.Value
Cells(BARIS, 5) = Me.EMAIL.Value

Call MsgBox("Data berhasil diubah", vbInformation, "Ubah Data")


Me.NAMAINJSTANSI.Value = ""
Me.Alamat.Value = ""
Me.TELPON.Value = ""
Me.EMAIL.Value = ""
End If
Unload Me
Sheet1.Select
End Sub

You might also like