User Form Search and Update Issues

Copper Contributor

Attached is workbook I am using to track Inventory. Under the first tab I have a Tools & Equip. tab. There is a macro that will bring up a user form to search for an item within the data base. I could then update the data in the user form and use the update button within the form to update the row of data. I have the code as good as I think I can make it but I am getting no where. Please help.

Thanks!

 

Below is the code:

 

Private Sub CommandButton1_Click()
Dim PRODUCT_ID As String
PRODUCT_ID = Trim(TextBox1.Text)
Worksheets("Sheet4").Cells(Row.Count, 2).End(xlUp).Row

For i = 2 To lastrow
If Worksheets("Sheet4").Cells(i, 1).Value = PRODUCT_ID Then
TextBox2.Text = Worksheets("Sheet4").Cells(i, 2).Value
ComboBox1.Text = Worksheets("Sheet4").Cells(i, 3).Value
ComboBox2.Text = Worksheets("Sheet4").Cells(i, 4).Value
TextBox5.Text = Worksheets("Sheet4").Cells(i, 5).Value
TextBox6.Text = Worksheets("Sheet4").Cells(i, 6).Value
TextBox7.Text = Worksheets("Sheet4").Cells(i, 7).Value
TextBox8.Text = Worksheets("Sheet4").Cells(i, 8).Value
TextBox9.Text = Worksheets("Sheet4").Cells(i, 9).Value
TextBox10.Text = Worksheets("Sheet4").Cells(i, 10).Value
TextBox11.Text = Worksheets("Sheet4").Cells(i, 11).Value
TextBox12.Text = Worksheets("Sheet4").Cells(i, 12).Value
TextBox13.Text = Worksheets("Sheet4").Cells(i, 13).Value

End If
Next

End Sub

Private Sub ToggleButton1_Click()
Dim PRODUCT_ID As String
PRODUCT_ID = Trim(TextBox1.Text)
lastrow = Worksheets("Sheet4").Cells(Row.Count, 2).End(xlUp).Row

For i = 2 To lastrow

If Worksheets("Sheet4").Cells(i, 1).Value = PRODUCT_ID Then
Worksheets("Sheet4").Cells(i, 2).Value = TextBox2.Text
Worksheets("Sheet4").Cells(i, 3).Value = ComboBox1.Text
Worksheets("Sheet4").Cells(i, 4).Value = ComboBox2.Text
Worksheets("Sheet4").Cells(i, 5).Value = TextBox5.Text
Worksheets("Sheet4").Cells(i, 6).Value = TextBox6.Text
Worksheets("Sheet4").Cells(i, 7).Value = TextBox7.Text
Worksheets("Sheet4").Cells(i, 8).Value = TextBox8.Text
Worksheets("Sheet4").Cells(i, 9).Value = TextBox9.Text
Worksheets("Sheet4").Cells(i, 10).Value = TextBox10.Text
Worksheets("Sheet4").Cells(i, 11).Value = TextBox11.Text
Worksheets("Sheet4").Cells(i, 12).Value = TextBox12.Text
Worksheets("Sheet4").Cells(i, 13).Value = TextBox13.Text

End If
Next

End Sub

2 Replies

@jdavis1994 

The ID number to get past the user form is 1234

@jdavis1994 

Issue resolved thanks to a contributor of this forum. See attached.