Search for Knowledge
“A mistake is a signal that it is time to learn something new, something you didn’t know before.”

Coding VBA Macro Excel

Coding VBA Macro Excel

Buat Terlebih dahulu label dan command Button
label1 (caption) =  Judul
label2 (caption) = Kas
label3 (caption) = Perlengkapan
label4 (caption) = Peralatan
label5 (caption) = akml pyt
label6 (caption) = Utang
label7 (caption) = Modal
label8 (caption) = Keterangan
Button1 (caption) = Masukkan Data
Button2 (caption) = Hapus Data
Button3 (caption) = Exit

Setelah semua diubah caption, Maka masukkan coding untuk button1(Masukkan data) dengan coding :

Private Sub CommandButton1_Click()
Dim Data As Long
Sheet1.Activate
Data = WorksheetFunction.CountA(Range(“A:A”))+1
Cells(Data, 1).Value = TextBox1.value
Cells(Data, 2).Value = TextBox2.value
Cells(Data, 3).Value = TextBox3.value
Cells(Data, 4).Value = TextBox4.value
Cells(Data, 5).Value = TextBox5.value
Cells(Data, 6).Value = TextBox6.value
Cells(Data, 7).Value = TextBox7.value
Cells(Data, 8).Value = TextBox8.value
End Sub

Untuk Coding Button 2 (Bersihkan) dengan coding :

Private Sub CommandButton2_Click()
TextBox1.text =” “
TextBox2.text =” “
TextBox3.text =” “
TextBox4.text =” “
TextBox5.text =” “
TextBox6.text =” “
TextBox7.text =” “
TextBox8.text =” “
End Sub

Untuk Coding Button 3 (Keluar) dengan coding :

Private Sub CommandButton3_Click()
Unload Me
End Sub