Hi,
I have found a code by JoeMo from back at 2012 that I have used.
Now I need it in another place and here I have empty cells in the range from where I get the names to check if files exists.
This results in that the empty cells get marked green as the filenames found in the folder, and I can't figure out how to solve this.
I don't want the empty cells to be marked green as the found files.
Anyone who can help me with this?
I have found a code by JoeMo from back at 2012 that I have used.
Now I need it in another place and here I have empty cells in the range from where I get the names to check if files exists.
This results in that the empty cells get marked green as the filenames found in the folder, and I can't figure out how to solve this.
I don't want the empty cells to be marked green as the found files.
Anyone who can help me with this?
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("F" & Rows.Count).End(xlUp).Row
Set rng = Range("F2", "F" & lrw)
fList = rng.Value
For i = LBound(fList, 1) To UBound(fList, 1)
myFile = Dir(pStr & fList(i, 1)) '& "*")
If Not myFile = vbNullString Then
rng.Cells(i).Interior.Color = vbGreen
End If
Next i
End Sub