I'm very new to VBA and tying to write a code that would find numbers and words in excel sheet
in this code i can search number but cannot search words
Private Sub CommandButton5_Click()
Dim product_id As String
product_id = Trim(TextBox1.Text)
lastrow = Worksheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Worksheets("sheet1").Cells(i, 1).Value = product_id Then
TextBox2.Text = Worksheets("sheet1").Cells(i, 2).Value
TextBox3.Text = Worksheets("sheet1").Cells(i, 3).Value
TextBox4.Text = Worksheets("sheet1").Cells(i, 4).Value
End If
Next
End Sub
Aucun commentaire:
Enregistrer un commentaire