I have a userform that has 1 combo box that retrieves info into 12 textboxes. I have 3 command buttons, Save info, Close, and Print Form. All works well except if you edit the info pulled into the textboxes, it saves the new info on a new row. What would be the correct code for the user to edit the info retrieved from the combobox and the info be saved to same row instead of a new row?
Here's a sample of my code to save the new info
Private Sub ComboBox1_Change()
TextBox1 = Sheets("Sheet1").Range("B" & ComboBox1.ListIndex + 2)
TextBox2 = Sheets("Sheet1").Range("C" & ComboBox1.ListIndex + 2)
TextBox3 = Sheets("Sheet1").Range("D" & ComboBox1.ListIndex + 2)
TextBox4 = Sheets("Sheet1").Range("E" & ComboBox1.ListIndex + 2)
TextBox5 = Sheets("Sheet1").Range("F" & ComboBox1.ListIndex + 2)
TextBox6 = Sheets("Sheet1").Range("G" & ComboBox1.ListIndex + 2)
TextBox7 = Sheets("Sheet1").Range("H" & ComboBox1.ListIndex + 2)
TextBox8 = Sheets("Sheet1").Range("I" & ComboBox1.ListIndex + 2)
TextBox9 = Sheets("Sheet1").Range("J" & ComboBox1.ListIndex + 2)
TextBox10 = Sheets("Sheet1").Range("K" & ComboBox1.ListIndex + 2)
TextBox11 = Sheets("Sheet1").Range("L" & ComboBox1.ListIndex + 2)
TextBox12 = Sheets("Sheet1").Range("M" & ComboBox1.ListIndex + 2)
End Sub
Here's what I use to save the info for NEW info.
ws.Cells(iRow, 1).Value = Me.ComboBox1.Value
ws.Cells(iRow, 2).Value = Me.TextBox1.Value
ws.Cells(iRow, 3).Value = Me.TextBox2.Value
ws.Cells(iRow, 4).Value = Me.TextBox3.Value
ws.Cells(iRow, 5).Value = Me.TextBox4.Value
ws.Cells(iRow, 6).Value = Me.TextBox5.Value
ws.Cells(iRow, 7).Value = Me.TextBox6.Value
ws.Cells(iRow, 8).Value = Me.TextBox7.Value
ws.Cells(iRow, 9).Value = Me.TextBox8.Value
ws.Cells(iRow, 10).Value = Me.TextBox9.Value
ws.Cells(iRow, 11).Value = Me.TextBox10.Value
ws.Cells(iRow, 12).Value = Me.TextBox11.Value
ws.Cells(iRow, 13).Value = Me.TextBox12.Value
Thanks so much for any guidance I can get! I'm at a loss for some reason.
Here's a sample of my code to save the new info
Private Sub ComboBox1_Change()
TextBox1 = Sheets("Sheet1").Range("B" & ComboBox1.ListIndex + 2)
TextBox2 = Sheets("Sheet1").Range("C" & ComboBox1.ListIndex + 2)
TextBox3 = Sheets("Sheet1").Range("D" & ComboBox1.ListIndex + 2)
TextBox4 = Sheets("Sheet1").Range("E" & ComboBox1.ListIndex + 2)
TextBox5 = Sheets("Sheet1").Range("F" & ComboBox1.ListIndex + 2)
TextBox6 = Sheets("Sheet1").Range("G" & ComboBox1.ListIndex + 2)
TextBox7 = Sheets("Sheet1").Range("H" & ComboBox1.ListIndex + 2)
TextBox8 = Sheets("Sheet1").Range("I" & ComboBox1.ListIndex + 2)
TextBox9 = Sheets("Sheet1").Range("J" & ComboBox1.ListIndex + 2)
TextBox10 = Sheets("Sheet1").Range("K" & ComboBox1.ListIndex + 2)
TextBox11 = Sheets("Sheet1").Range("L" & ComboBox1.ListIndex + 2)
TextBox12 = Sheets("Sheet1").Range("M" & ComboBox1.ListIndex + 2)
End Sub
Here's what I use to save the info for NEW info.
ws.Cells(iRow, 1).Value = Me.ComboBox1.Value
ws.Cells(iRow, 2).Value = Me.TextBox1.Value
ws.Cells(iRow, 3).Value = Me.TextBox2.Value
ws.Cells(iRow, 4).Value = Me.TextBox3.Value
ws.Cells(iRow, 5).Value = Me.TextBox4.Value
ws.Cells(iRow, 6).Value = Me.TextBox5.Value
ws.Cells(iRow, 7).Value = Me.TextBox6.Value
ws.Cells(iRow, 8).Value = Me.TextBox7.Value
ws.Cells(iRow, 9).Value = Me.TextBox8.Value
ws.Cells(iRow, 10).Value = Me.TextBox9.Value
ws.Cells(iRow, 11).Value = Me.TextBox10.Value
ws.Cells(iRow, 12).Value = Me.TextBox11.Value
ws.Cells(iRow, 13).Value = Me.TextBox12.Value
Thanks so much for any guidance I can get! I'm at a loss for some reason.