Hi all,
I have this which I am trying to input a list of names of which the match could be in any of 4 columns....
This all works, BUT, if for example I put in 'sarah' and 'ddddsaarhcccc' is in the data dump then both 'sarah' and 'ddddsaarhcccc' are found.
But i only want to find 'sarah'
Can someone please help. I cant seem to work it out.
'Clear all
Ws4.Cells.ClearContents
'First the Headers
ws2.Range("2:2").Copy Destination:=PasteRng
Set PasteRng = PasteRng.Offset(1, 0)
Dim a As Long
Dim search As Long
Dim row As Long
Dim col As Long
Dim flag As Integer
search = 1
row = 3
col = 4
While Not Sheets("Servers To Find").Cells(search, 1) = Empty
row = 3
While Not Sheets("Physical Servers").Cells(row, 1) = Empty
If InStr(LCase(Sheets("Physical Servers").Cells(row, col)), LCase(Sheets("Servers To Find").Cells(search, 1))) > 0 Then
'If InStr(Sheets("Physical Servers").Cells(row, col), Sheets("Servers To Find").Cells(search, 1)) > 0 Then
Sheets("Physical Servers").Cells(row, col).EntireRow.Copy Destination:=PasteRng
Set PasteRng = PasteRng.Offset(1, 0)
flag = 1
End If
row = row + 1
Wend
If flag = 0 Then
col = 5
row = 3
While Not Sheets("Physical Servers").Cells(row, col) = Empty
If InStr(LCase(Sheets("Physical Servers").Cells(row, col)), LCase(Sheets("Servers To Find").Cells(search, 1))) > 0 Then
Sheets("Physical Servers").Cells(row, col).EntireRow.Copy Destination:=PasteRng
Set PasteRng = PasteRng.Offset(1, 0)
End If
row = row + 1
Wend
End If
col = 4
search = search + 1
Wend
Bookmarks