Greetings, I wrote some code to highlight a whole line if the text inputed by the user in up to 3 textboxes were found in a certain cell of that line. Someone was kind enough to edit the code for me to output a cell's content starting at cell B3 everytime the search is positive for a certain line, instead of highlighting the text.
However I get a "Next without For" error (I had to translate so this might not be 100% accurate) with the code. It's probably something very simple to fix but my coding skills are non-existent.
Thanks in advance.
Private Sub CommandButton1_Click()
Dim c3 As Range
Dim DstRange As Range
Dim f As String
Dim Item As Variant
Dim R As Long
Dim srchArray As Variant
Dim SrchRng3 As Range
Set DstRange = ActiveSheet.Range("B3")
Set SrchRng3 = ActiveSheet.Range("H1", ActiveSheet.Range("H100").End(xlUp))
srchArray = Array(TextBox1.Text, TextBox2.Text, TextBox3.Text)
For Each Item In srchArray
Set c3 = SrchRng3.Find(Item, , xlValues, xlWhole, xlByRows, xlNext, False)
If Not c3 Is Nothing Then
f = c3.Address
Do While Not c3 Is Nothing
DstRange.Offset(R, 0) = c3.Value
R = R + 1
Set c3 = SrchRng3.FindNext(c3)
If c3.Address = f Then Exit Do
Loop
Next Item
End Sub
Bookmarks