Mari kita mulai dengan langkah-langkah sebagai berikut :
- Buka file excel 2007
- Double Klik di nama worksheet lalu ganti nama yg asalnya Sheet1 menjadi “1770SS” dan Sheet2 menjadi “1770SSdata” (ini mah klo saya, klo anda terserah tapi perlu diingat namanya untuk pembuatan code)
Biar gampang mah download aja disini
Kemudian kita simpan file sebagai excel makro….klik file save as pilih Excel Macro Enabled Workbook….ketik nama file disini saya beri nama file “1770SS”
Langkah selanjutnya adalah design form dengan Control yang akan kita gunakan adalah : Control Label, Textbox, Command Button dan frame adapun langkah-langkahnya seperti sudah saya bahas pada pembahasan sebelumnya (MEMBUAT FORM ISIAN DATA SEDERHANA DI EXCEL)
Langkah selanjutnya adalah memberi nama dan caption untuk tiap label, textbox dan command button
- Frame 1 Name “IDENTITAS Caption “IDENTITAS”
- Label Caption : “NPWP, NAMA WAJIB PAJAK, PEKERJAAN, KLU, NO TELEPON, NO FAXIMILE, LAPORAN PERUBAHAN DATA, TERSENDIRI, TIDAK ADA, JUMLAH KESELURUHAN HARTA YANG DIMILIKI PADA AKHIR TAHUN,Rp., JUMLAH KESELURUHAN KEWAJIBAN/UTANG PADA AKHIR TAHUN dan TANGGAL”
- Textbox name : NPWP1 sampai dengan NPWP15 (untuk pengisian No NPWP)
- Textbox name : NAMA1 sampai dengan NAMA32 (untuk pengisian Nama)
- Textbox name : PEK1 sampai dengan PEK23 (untuk pengisian Pekerjaan)
- Textbox name : KLU1 sampai dengan KLU6 (untuk pengisian KLU biasanya dikosongkan)
- Textbox name : TLP1 sampai dengan TLP12 (untuk pengisian No Telepon)
- Textbox name : FAX1 sampai dengan FAX12 (untuk pengisian No Fax)
- Textbox name : PD1 (untuk pengisian Perubahan Data)
- Textbox name : PD2 (untuk pengisian Lampiran Tersendiri)
- Textbox name : HARTA (untuk pengisian HARTA YANG DIMILIKI PADA AKHIR TAHUN)
- Textbox name : UTANG (untuk pengisian UTANG YANG PADA AKHIR TAHUN)
- Textbox name : TGL1 sampai dengan TGL8 (untuk pengisian tanggal bulan dan tahun)
- CommandButton1 name dan Caption : TAMBAH
- CommandButton2 name dan Caption : TUTUP
Sub F1770SS()
Form1770SS.Show
End Sub
Code yang dipakai CommandButton TUTUP
Private Sub CMTUTUP_Click()
Unload Me
End Sub
Code yang dipakai CommandButton TAMBAH
Private Sub TAMBAH_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets(“1770SSdata”)
‘menemukan baris kosong pada database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
iNomor = ws.Cells(iRow – 1, 1).Value
iNomor = iNomor + 1
‘check untuk sebuah kode
If Trim(Me.NPWP1.Value) = “” Then
Me.NPWP1.SetFocus
MsgBox “Iiiiccchhh…..Data masih kosong tuuuhhhh….!!!!!”
Exit Sub
End If
‘copy data ke database
‘ NPWP
ws.Cells(iRow, 1).Value = iNomor
ws.Cells(iRow, 2).Value = Me.NPWP1.Value
ws.Cells(iRow, 3).Value = Me.NPWP2.Value
ws.Cells(iRow, 4).Value = Me.NPWP3.Value
ws.Cells(iRow, 5).Value = Me.NPWP4.Value
ws.Cells(iRow, 6).Value = Me.NPWP5.Value
ws.Cells(iRow, 7).Value = Me.NPWP6.Value
ws.Cells(iRow, 8).Value = Me.NPWP7.Value
ws.Cells(iRow, 9).Value = Me.NPWP8.Value
ws.Cells(iRow, 10).Value = Me.NPWP9.Value
ws.Cells(iRow, 11).Value = Me.NPWP10.Value
ws.Cells(iRow, 12).Value = Me.NPWP11.Value
ws.Cells(iRow, 13).Value = Me.NPWP12.Value
ws.Cells(iRow, 14).Value = Me.NPWP13.Value
ws.Cells(iRow, 15).Value = Me.NPWP14.Value
ws.Cells(iRow, 16).Value = Me.NPWP15.Value
‘NAMA
ws.Cells(iRow, 17).Value = Me.NAMA1.Value
ws.Cells(iRow, 18).Value = Me.NAMA2.Value
ws.Cells(iRow, 19).Value = Me.NAMA3.Value
ws.Cells(iRow, 20).Value = Me.NAMA4.Value
ws.Cells(iRow, 21).Value = Me.NAMA5.Value
ws.Cells(iRow, 22).Value = Me.NAMA6.Value
ws.Cells(iRow, 23).Value = Me.NAMA7.Value
ws.Cells(iRow, 24).Value = Me.NAMA8.Value
ws.Cells(iRow, 25).Value = Me.NAMA9.Value
ws.Cells(iRow, 26).Value = Me.NAMA10.Value
ws.Cells(iRow, 27).Value = Me.NAMA11.Value
ws.Cells(iRow, 28).Value = Me.NAMA12.Value
ws.Cells(iRow, 29).Value = Me.NAMA13.Value
ws.Cells(iRow, 30).Value = Me.NAMA14.Value
ws.Cells(iRow, 31).Value = Me.NAMA15.Value
ws.Cells(iRow, 32).Value = Me.NAMA16.Value
ws.Cells(iRow, 33).Value = Me.NAMA17.Value
ws.Cells(iRow, 34).Value = Me.NAMA18.Value
ws.Cells(iRow, 35).Value = Me.NAMA19.Value
ws.Cells(iRow, 36).Value = Me.NAMA20.Value
ws.Cells(iRow, 37).Value = Me.NAMA21.Value
ws.Cells(iRow, 38).Value = Me.NAMA22.Value
ws.Cells(iRow, 39).Value = Me.NAMA23.Value
ws.Cells(iRow, 40).Value = Me.NAMA24.Value
ws.Cells(iRow, 41).Value = Me.NAMA25.Value
ws.Cells(iRow, 42).Value = Me.NAMA26.Value
ws.Cells(iRow, 43).Value = Me.NAMA27.Value
ws.Cells(iRow, 44).Value = Me.NAMA28.Value
ws.Cells(iRow, 45).Value = Me.NAMA29.Value
ws.Cells(iRow, 46).Value = Me.NAMA30.Value
ws.Cells(iRow, 47).Value = Me.NAMA31.Value
ws.Cells(iRow, 48).Value = Me.NAMA32.Value
‘PEKERJAAN
ws.Cells(iRow, 49).Value = Me.PEK1.Value
ws.Cells(iRow, 50).Value = Me.PEK2.Value
ws.Cells(iRow, 51).Value = Me.PEK3.Value
ws.Cells(iRow, 52).Value = Me.PEK4.Value
ws.Cells(iRow, 53).Value = Me.PEK5.Value
ws.Cells(iRow, 54).Value = Me.PEK6.Value
ws.Cells(iRow, 55).Value = Me.PEK7.Value
ws.Cells(iRow, 56).Value = Me.PEK8.Value
ws.Cells(iRow, 57).Value = Me.PEK9.Value
ws.Cells(iRow, 58).Value = Me.PEK10.Value
ws.Cells(iRow, 59).Value = Me.PEK11.Value
ws.Cells(iRow, 60).Value = Me.PEK12.Value
ws.Cells(iRow, 61).Value = Me.PEK13.Value
ws.Cells(iRow, 62).Value = Me.PEK14.Value
ws.Cells(iRow, 63).Value = Me.PEK15.Value
ws.Cells(iRow, 64).Value = Me.PEK16.Value
ws.Cells(iRow, 65).Value = Me.PEK17.Value
ws.Cells(iRow, 66).Value = Me.PEK18.Value
ws.Cells(iRow, 67).Value = Me.PEK19.Value
ws.Cells(iRow, 68).Value = Me.PEK20.Value
ws.Cells(iRow, 69).Value = Me.PEK21.Value
ws.Cells(iRow, 70).Value = Me.PEK22.Value
ws.Cells(iRow, 71).Value = Me.PEK23.Value
‘KLU
ws.Cells(iRow, 72).Value = Me.KLU1.Value
ws.Cells(iRow, 73).Value = Me.KLU2.Value
ws.Cells(iRow, 74).Value = Me.KLU3.Value
ws.Cells(iRow, 75).Value = Me.KLU4.Value
ws.Cells(iRow, 76).Value = Me.KLU5.Value
ws.Cells(iRow, 77).Value = Me.KLU6.Value
‘TLP
ws.Cells(iRow, 78).Value = Me.TLP1.Value
ws.Cells(iRow, 79).Value = Me.TLP2.Value
ws.Cells(iRow, 80).Value = Me.TLP3.Value
ws.Cells(iRow, 81).Value = Me.TLP4.Value
ws.Cells(iRow, 82).Value = Me.TLP5.Value
ws.Cells(iRow, 83).Value = Me.TLP6.Value
ws.Cells(iRow, 84).Value = Me.TLP7.Value
ws.Cells(iRow, 85).Value = Me.TLP8.Value
ws.Cells(iRow, 86).Value = Me.TLP9.Value
ws.Cells(iRow, 87).Value = Me.TLP10.Value
ws.Cells(iRow, 88).Value = Me.TLP11.Value
ws.Cells(iRow, 89).Value = Me.TLP12.Value
‘FAX
ws.Cells(iRow, 90).Value = Me.FAX1.Value
ws.Cells(iRow, 91).Value = Me.FAX2.Value
ws.Cells(iRow, 92).Value = Me.FAX3.Value
ws.Cells(iRow, 93).Value = Me.FAX4.Value
ws.Cells(iRow, 94).Value = Me.FAX5.Value
ws.Cells(iRow, 95).Value = Me.FAX6.Value
ws.Cells(iRow, 96).Value = Me.FAX7.Value
ws.Cells(iRow, 97).Value = Me.FAX8.Value
ws.Cells(iRow, 98).Value = Me.FAX9.Value
ws.Cells(iRow, 99).Value = Me.FAX10.Value
ws.Cells(iRow, 100).Value = Me.FAX11.Value
ws.Cells(iRow, 101).Value = Me.FAX12.Value
‘PD
ws.Cells(iRow, 102).Value = Me.PD1.Value
ws.Cells(iRow, 103).Value = Me.PD2.Value
‘HARTA
ws.Cells(iRow, 104).Value = Me.HARTA.Value
‘UTANG
ws.Cells(iRow, 105).Value = Me.UTANG.Value
‘TGL
ws.Cells(iRow, 106).Value = Me.TGL1.Value
ws.Cells(iRow, 107).Value = Me.TGL2.Value
ws.Cells(iRow, 108).Value = Me.TGL3.Value
ws.Cells(iRow, 109).Value = Me.TGL4.Value
ws.Cells(iRow, 110).Value = Me.TGL5.Value
ws.Cells(iRow, 111).Value = Me.TGL6.Value
ws.Cells(iRow, 112).Value = Me.TGL7.Value
ws.Cells(iRow, 113).Value = Me.TGL8.Value
‘clear data
Me.NPWP1.Value = “”
Me.NPWP2.Value = “”
Me.NPWP3.Value = “”
Me.NPWP4.Value = “”
Me.NPWP5.Value = “”
Me.NPWP6.Value = “”
Me.NPWP7.Value = “”
Me.NPWP8.Value = “”
Me.NPWP9.Value = “”
Me.NPWP10.Value = “”
Me.NPWP11.Value = “”
Me.NPWP12.Value = “”
Me.NPWP13.Value = “”
Me.NPWP14.Value = “”
Me.NPWP15.Value = “”
‘NAMA
Me.NAMA1.Value = “”
Me.NAMA2.Value = “”
Me.NAMA3.Value = “”
Me.NAMA4.Value = “”
Me.NAMA5.Value = “”
Me.NAMA6.Value = “”
Me.NAMA7.Value = “”
Me.NAMA8.Value = “”
Me.NAMA9.Value = “”
Me.NAMA10.Value = “”
Me.NAMA11.Value = “”
Me.NAMA12.Value = “”
Me.NAMA13.Value = “”
Me.NAMA14.Value = “”
Me.NAMA15.Value = “”
Me.NAMA16.Value = “”
Me.NAMA17.Value = “”
Me.NAMA18.Value = “”
Me.NAMA19.Value = “”
Me.NAMA20.Value = “”
Me.NAMA21.Value = “”
Me.NAMA22.Value = “”
Me.NAMA23.Value = “”
Me.NAMA24.Value = “”
Me.NAMA25.Value = “”
Me.NAMA26.Value = “”
Me.NAMA27.Value = “”
Me.NAMA28.Value = “”
Me.NAMA29.Value = “”
Me.NAMA30.Value = “”
Me.NAMA31.Value = “”
Me.NAMA32.Value = “”
Me.PEK1.Value = “”
Me.PEK2.Value = “”
Me.PEK3.Value = “”
Me.PEK4.Value = “”
Me.PEK5.Value = “”
Me.PEK6.Value = “”
Me.PEK7.Value = “”
Me.PEK8.Value = “”
Me.PEK9.Value = “”
Me.PEK10.Value = “”
Me.PEK11.Value = “”
Me.PEK12.Value = “”
Me.PEK13.Value = “”
Me.PEK14.Value = “”
Me.PEK15.Value = “”
Me.PEK16.Value = “”
Me.PEK17.Value = “”
Me.PEK18.Value = “”
Me.PEK19.Value = “”
Me.PEK20.Value = “”
Me.PEK21.Value = “”
Me.PEK22.Value = “”
Me.PEK23.Value = “”
Me.KLU1.Value = “”
Me.KLU2.Value = “”
Me.KLU3.Value = “”
Me.KLU4.Value = “”
Me.KLU5.Value = “”
Me.KLU6.Value = “”
Me.TLP1.Value = “”
Me.TLP2.Value = “”
Me.TLP3.Value = “”
Me.TLP4.Value = “”
Me.TLP5.Value = “”
Me.TLP6.Value = “”
Me.TLP7.Value = “”
Me.TLP8.Value = “”
Me.TLP9.Value = “”
Me.TLP10.Value = “”
Me.TLP11.Value = “”
Me.TLP12.Value = “”
Me.FAX1.Value = “”
Me.FAX2.Value = “”
Me.FAX3.Value = “”
Me.FAX4.Value = “”
Me.FAX5.Value = “”
Me.FAX6.Value = “”
Me.FAX7.Value = “”
Me.FAX8.Value = “”
Me.FAX9.Value = “”
Me.FAX10.Value = “”
Me.FAX11.Value = “”
Me.FAX12.Value = “”
Me.PD1.Value = “”
Me.PD2.Value = “”
Me.HARTA.Value = “”
Me.UTANG.Value = “”
Me.TGL1.Value = “”
Me.TGL2.Value = “”
Me.TGL3.Value = “”
Me.TGL4.Value = “”
Me.TGL5.Value = “”
Me.TGL6.Value = “”
Me.TGL7.Value = “”
Me.TGL8.Value = “”
Me.NPWP1.SetFocus
End Sub
Untuk menghindari menutup melalui tanda X pada form masukan kode dibawah ini dengan klik kanan mouse pada form dan pilih view code dan ketikan kode dibawah ini :
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox “MAKE TOMBOL ATUH KANG!”
End If
End Sub
Tidak ada komentar:
Posting Komentar