I have a user form which the user is entering data into a large spreadsheet.
The first part of the userform is a combobox to enter the week number. This is the key which dictates where the remaining data needs to go.
On a separate sheet I have a range (G12:AF12). What I am trying to do is to have the input from the Combobox to dictate which row the data should be stored.
For example if the combobox value is 42 then the macro will look in the range G12:af12, when it finds the row with 42 in it, the remaining entered data from the userform will be entered in this row.
I have tried the following but it does not work and seems a lot of coding for something so simple.
Private Sub CommandButton1_Click()
Sheets("kpi data").Activate
If Cells(12, 7).Value = ComboBox1.Value Then Cells(28, 7).Value = TextBox1.Value
If Cells(12, 7).Value = ComboBox1.Value Then Cells(30, 7).Value = TextBox2.Value
If Cells(12, 7).Value = ComboBox1.Value Then Cells(27, 7).Value = TextBox3.Value
If Cells(12, 7).Value = ComboBox1.Value Then Cells(15, 7).Value = TextBox4.Value
If Cells(12, 7).Value = ComboBox1.Value Then Cells(16, 7).Value = TextBox5.Value
If Cells(12, 7).Value = ComboBox1.Value Then Cells(20, 7).Value = TextBox6.Value
If Cells(12, 7).Value = ComboBox1.Value Then Cells(19, 7).Value = TextBox7.Value
If Cells(12, 7).Value = ComboBox1.Value Then Cells(23, 7).Value = TextBox8.Value
MsgBox ("Data Submitted, thank you")
Sheets("Mainscreen").Activate
UserForm1.Hide
End Sub
As you can tell I am new to VBA and any help would be gratefully received.
Thank you in advance