Hi All,
Can someone please help with the following.
I am using the following script which highlights the entire row of found values.
I would like a modified script which would copy the rows of the found values into a listbox.
Also a script which would copy not the entire row of the found values into the listbox but values in columns A, C, F, G of the found values.
Lastly a script which would copy the rows of the found values from sheet named contacts to sheet named contacts2.
Can someone please help with the following.
I am using the following script which highlights the entire row of found values.
I would like a modified script which would copy the rows of the found values into a listbox.
Also a script which would copy not the entire row of the found values into the listbox but values in columns A, C, F, G of the found values.
Lastly a script which would copy the rows of the found values from sheet named contacts to sheet named contacts2.
Code:
Sub Test()
Dim hCell As Range
Dim strName As String
ReDim arr(4) As String
Dim rw, i As Long
' change the following values to what you want, non case senstive
arr(1) = Sheets("Contacts").Range("A3").Value
arr(2) = "Temp1"
arr(3) = "Temp2"
arr(4) = "Temp3"
For Each hCell In Sheets("Contacts").Range("A4:A2000")
For i = 1 To UBound(arr)
strName = arr(i)
Set FOUND = hCell.Find(strName, , , xlPart)
If Not FOUND Is Nothing Then
rw = hCell.Find(strName, , , xlPart).Row
Rows(rw).EntireRow.Interior.ColorIndex = 6
' copy row values into listbox1
Else: End If
Next i
Next
End Sub