matching the output and displaying the data
i try to write the coding for search button...
but i my case the output just select only one row..how i want to display the output for and match the data?
Private Sub CommandButton1_Click()
Dim response
Dim i As Integer
i = 2
'Find the value in worksheet based on the string of text box
Do While Worksheets("Sheet1").Cells(i, 2).Value <> ComboBox1.Text
i = i + 1
'Generate msg box if the value does not found
If IsEmpty(Worksheets("Sheet1").Cells(i, 2).Value) = True Then
response = MsgBox("DATA NOT FOUND...!!!", vbInformation, "Warning...!!!")
'Clearing text boxes after warning msg box
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
Exit Do
End If
Loop
'Set each text boxes with the found value from worksheet
If Worksheets("Sheet1").Cells(i, 2).Value = ComboBox1.Text Then
TextBox1.Text = Worksheets("Sheet1").Cells(i, 1).Value
TextBox2.Text = Worksheets("sheet1").Cells(i, 2).Value
TextBox3.Text = Worksheets("sheet1").Cells(i, 3).Value
TextBox4.Text = Worksheets("Sheet1").Cells(i, 4).Value
TextBox5.Text = Worksheets("sheet1").Cells(i, 5).Value
TextBox6.Text = Worksheets("sheet1").Cells(i, 6).Value
End If
End Sub
|