Input ketabel pilihan dengan Combobox1 sebagai
kunci pilihan ke table baris
Kode input pastekan di
CommandButton1
Private
Sub CommandButton4_Click()
If
ComboBox1.Text = "Tabel1" Then
Dim iRow As Long
Sheets("Sheet1").Activate
iRow =
WorksheetFunction.CountA(Range("b3:b10")) + 3
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("b13:b20"))
+ 13
Cells(aRow, 2).Value =
TextBox1.Value
Cells(aRow, 3).Value =
TextBox2.Value
Cells(aRow, 4).Value =
TextBox3.Value
Cells(aRow, 5).Value =
TextBox4.Value
ElseIf
ComboBox1.Text = "Tabel3" Then
Dim bRow As Long
Sheets("Sheet1").Activate
bRow =
WorksheetFunction.CountA(Range("b23:b30")) + 23
Cells(bRow, 2).Value =
TextBox1.Value
Cells(bRow, 3).Value =
TextBox2.Value
Cells(bRow, 4).Value =
TextBox3.Value
Cells(bRow, 5).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