Input ketabel pilihan dengan Combobox1 sebagai
kunci pilihan ke table Kolom
Kode input pastekan di CommandButton1
Private Sub CommandButton1_Click()
If ComboBox1.Text = "Tabel1" Then
Dim iRow As Long
Sheets("Sheet1").Activate
iRow =
WorksheetFunction.CountA(Range("b6:b50")) + 6
‘dimulai baris
ke 6 kolom ke 2
Cells(iRow, 2).Value =
TextBox1.Value
Cells(iRow, 3).Value =
TextBox2.Value
Cells(iRow, 4).Value =
TextBox3.Value
Cells(iRow, 5).Value =
TextBox4.Value
ElseIf ComboBox1.Text = "Tabel2" Then
Dim aRow As Long
Sheets("Sheet1").Activate
aRow =
WorksheetFunction.CountA(Range("g6:g50")) + 6
‘dimulai baris
ke 6 kolom ke 7
Cells(aRow, 7).Value =
TextBox1.Value
Cells(aRow, 8).Value =
TextBox2.Value
Cells(aRow, 9).Value =
TextBox3.Value
Cells(aRow, 10).Value =
TextBox4.Value
ElseIf ComboBox1.Text = "Tabel3" Then
Dim cRow As Long
Sheets("Sheet1").Activate
cRow =
WorksheetFunction.CountA(Range("L6:L50")) + 6
‘dimulai baris
ke 6 kolom ke 12
Cells(cRow, 12).Value =
TextBox1.Value
Cells(cRow, 13).Value =
TextBox2.Value
Cells(cRow, 14).Value =
TextBox3.Value
Cells(cRow, 15).Value = TextBox4.Value
End If
End Sub
Private Sub
UserForm_Initialize()
ComboBox1.AddItem "Tabel1"
ComboBox1.AddItem "Tabel2"
ComboBox1.AddItem "Tabel3"
End Sub
No comments:
Post a Comment