James006 helped me to solve one part of this code, thanks.
The issue I have now is that I thought this to be case sensitive, but it's not.
If I have a file in the folder named 8PQ9800-0AA12_13_aLL.pdf and the search critera is 8PQ9800-0AA12_13_ALL.pdf it should not "find it" and mark it green since the names differ.
In conditional formating i use EXACT to do this with an IF statement =IF($M2="";"";IF(EXACT($N2;$F2);1;0))
But I can't figure out how to do this in the code below.
The issue I have now is that I thought this to be case sensitive, but it's not.
If I have a file in the folder named 8PQ9800-0AA12_13_aLL.pdf and the search critera is 8PQ9800-0AA12_13_ALL.pdf it should not "find it" and mark it green since the names differ.
In conditional formating i use EXACT to do this with an IF statement =IF($M2="";"";IF(EXACT($N2;$F2);1;0))
But I can't figure out how to do this in the code below.
VBA Code:
Sub LookForFiles()
Dim pStr As String, myFile As String, rng As Range, lrw As Long
Dim fList As Variant
pStr = ActiveWorkbook.Path & "\" 'pStr = "The Path to Your Folder Here" 'Path to folder including final \
lrw = Range("E" & Rows.Count).End(xlUp).Row
Set rng = Range("E2", "E" & lrw)
fList = rng.Value
For i = LBound(fList, 1) To UBound(fList, 1)
myFile = Dir(pStr & fList(i, 1) & "*")
If Not myFile = vbNullString Then
If rng.Cells(i).Value <> "" Then
rng.Cells(i).Interior.Color = RGB(169, 208, 142) 'rng.Cells(i).Interior.Color = vbGreen
End If
Next i
End Sub