WHAT AM I DOING WRONG
I am trying to make a form in Excel that can update different tables on separate sheets depending on which sheet has been picked in a ComboBox. Can anyone please tell me what I am doing wrong:
I am trying to make a form in Excel that can update different tables on separate sheets depending on which sheet has been picked in a ComboBox. Can anyone please tell me what I am doing wrong:
Code:
[FONT=Lucida Grande]Private Sub CommandButton1_Click()[/FONT][FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]If ComboBox1.Text = "R&D" Then[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]Range("'R&D'!A2").Select[/FONT]
[FONT=Lucida Grande]ActiveCell.End(xlDown).Select[/FONT]
[FONT=Lucida Grande]lastrow = ActiveCell.Row[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 1).Value = TextBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 2).Value = ComboBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 3).Value = TextBox3.Text[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]ElseIf ComboBox1.Text = "Sales" Then[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]Range("'Sales'!A2").Select[/FONT]
[FONT=Lucida Grande]ActiveCell.End(xlDown).Select[/FONT]
[FONT=Lucida Grande]lastrow = ActiveCell.Row[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 1).Value = TextBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 2).Value = ComboBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 3).Value = TextBox3.Text[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]ElseIf ComboBox1.Text = "Marketing" Then[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]Range("'Marketing'!A2").Select[/FONT]
[FONT=Lucida Grande]ActiveCell.End(xlDown).Select[/FONT]
[FONT=Lucida Grande]lastrow = ActiveCell.Row[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 1).Value = TextBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 2).Value = ComboBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 3).Value = TextBox3.Text[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]ElseIf ComboBox1.Text = "Finance" Then[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]Range("'Finance'!A2").Select[/FONT]
[FONT=Lucida Grande]ActiveCell.End(xlDown).Select[/FONT]
[FONT=Lucida Grande]lastrow = ActiveCell.Row[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 1).Value = TextBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 2).Value = ComboBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 3).Value = TextBox3.Text[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]ElseIf ComboBox1.Text = "Accounting" Then[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]Range("'Accounting'!A2").<wbr>Select[/FONT]
[FONT=Lucida Grande]ActiveCell.End(xlDown).Select[/FONT]
[FONT=Lucida Grande]lastrow = ActiveCell.Row[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 1).Value = TextBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 2).Value = ComboBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 3).Value = TextBox3.Text[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]ElseIf ComboBox1.Text = "Legal" Then[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]Range("'Legal'!A2").Select[/FONT]
[FONT=Lucida Grande]ActiveCell.End(xlDown).Select[/FONT]
[FONT=Lucida Grande]lastrow = ActiveCell.Row[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 1).Value = TextBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 2).Value = ComboBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 3).Value = TextBox3.Text[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]Else[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]Range("'WEBSITE'!A2").Select[/FONT]
[FONT=Lucida Grande]ActiveCell.End(xlDown).Select[/FONT]
[FONT=Lucida Grande]lastrow = ActiveCell.Row[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 1).Value = TextBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 2).Value = ComboBox2.Text[/FONT]
[FONT=Lucida Grande]Cells(lastrow + 1, 3).Value = TextBox3.Text[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]End If[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]
[/FONT]
[FONT=Lucida Grande]End Sub[/FONT]