Pastekan kode berikut
pada tombol tambah
Private Sub CommandButton1_Click()
Dim Arow
As Long
'Deklarasi
arow input atau mengisi baris terakhir pada sheet1
Arow =
Worksheets("sheet1").Cells(Rows.Count, 2).End(xlUp).Offset(1, 1).Row
Worksheets("sheet1").Cells(Arow,
2).Value = TextBox1.Value
Worksheets("sheet1").Cells(Arow,
4).Value = TextBox3.Value
‘True artinya dipilih atau di klik
‘Jika OptionButton1 di klik
If
OptionButton1.Value
= True Then
Worksheets("sheet1").Cells(Arow,
3).Value = "Pegawai"
‘Jika OptionButton2 di klik
ElseIf
OptionButton2.Value
= True Then
Worksheets("sheet1").Cells(Arow,
3).Value = "Pengusaha"
‘Jika OptionButton3 di klik
ElseIf
OptionButton3.Value
= True Then
Worksheets("sheet1").Cells(Arow,
3).Value = "Karyawan"
Else
End If
End Sub
No comments:
Post a Comment