Hi all,
Below is my coding that helps me search for a word/name in a certain column and return data that relates to this word/name. The values are returned in a neat userform. The only issue I have is that the text I search for may not be unique. There may be 2 or 3 other instances of this word/name. i.e I search for John Smith and it returns age, location etc etc. But my search will stop at the first John Smith found. Is there a piece of coding I can put in that will cycle through all the John Smiths and not just stop at the first instance found. Thanks in advance.
Private Sub txtTAname_Change()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Charolais SNPs Parentage")
wsLR = ws.Cells(Rows.Count, 18).End(xlUp).Row
For x = 6 To wsLR
If ws.Cells(x, 18) = Me.txtTAname Then
Me.txtTAnumber = ws.Cells(x, "O")
Me.txtTAstatus = ws.Cells(x, "V")
Me.txtSname = ws.Cells(x, "AC")
Me.txtSstatus = ws.Cells(x, "AF")
Me.txtDname = ws.Cells(x, "X")
Me.txtDstatus = ws.Cells(x, "AA")
Me.txtTAid = ws.Cells(x, "N")
Exit Sub
End If
Next x
End Sub
Below is my coding that helps me search for a word/name in a certain column and return data that relates to this word/name. The values are returned in a neat userform. The only issue I have is that the text I search for may not be unique. There may be 2 or 3 other instances of this word/name. i.e I search for John Smith and it returns age, location etc etc. But my search will stop at the first John Smith found. Is there a piece of coding I can put in that will cycle through all the John Smiths and not just stop at the first instance found. Thanks in advance.
Private Sub txtTAname_Change()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Charolais SNPs Parentage")
wsLR = ws.Cells(Rows.Count, 18).End(xlUp).Row
For x = 6 To wsLR
If ws.Cells(x, 18) = Me.txtTAname Then
Me.txtTAnumber = ws.Cells(x, "O")
Me.txtTAstatus = ws.Cells(x, "V")
Me.txtSname = ws.Cells(x, "AC")
Me.txtSstatus = ws.Cells(x, "AF")
Me.txtDname = ws.Cells(x, "X")
Me.txtDstatus = ws.Cells(x, "AA")
Me.txtTAid = ws.Cells(x, "N")
Exit Sub
End If
Next x
End Sub