Sir, i am trying very hard to solve this. Please help. I made many TextBoxes on user form like textbox1, 2, 3, 4, 5, 6, 7, 8 to 16. I have data for example like this I want to Put a name in Combobox and want to show First search result's Name in TextBox1, Age in textbox2 City in Textbox3, Then loop search same value in next cell, if Found then His name in Textbox 4, Age in Textbox5, City in Textbox 6 and so on (Maximum 4 result to be found). I am using following code but its showing only First found result in Textbox1, Textbox2 & Textbox3 but Second found result not popup in Textbox4, 5 & 6. Please help : Code is as follows
Private Sub CommandButton1_Click()
Dim fnd As String, FirstFound As String
Dim FoundCell As Range, rng As Range
Dim myRange As Range, LastCell As Range
Dim a, b, c As Integer
a = 1
b = 2
c = 3
fnd = ComboBox1.Value
Set myRange = Sheets("Data").Range("B4:B50")
Set LastCell = myRange.Cells(myRange.Cells.Count)
Set FoundCell = myRange.Find(What:=fnd, After:=LastCell)
If Not FoundCell Is Nothing Then
FirstFound = FoundCell.Address
Else
GoTo NothingFound
End If
Set rng = FoundCell
Do Until FoundCell Is Nothing
UserForm1.Controls("TextBox" & a).Text = FoundCell.Offset(0, 0).Value
UserForm1.Controls("TextBox" & b).Text = FoundCell.Offset(0, 1).Value
UserForm1.Controls("TextBox" & c).Text = FoundCell.Offset(0, 2).Value
a = a + 3
b = b + 3
c = c + 3
If FoundCell.Address = FirstFound Then Exit Do
Loop
Exit Sub
NothingFound:
TextBox1.Text = "not found"
TextBox2.Text = "not found"
TextBox3.Text = "not found"
End Sub
Please help me to sort this out. I had searched hundreds of website but stuck at this point. Thanks a lot in Advance