Kmahraz
Member
Hello - Looking for some to help modify the code below so that it looks for a file name that contains a string VS an exact match
Code:
Sub Run()
Dim LRow As Integer
Dim LPath As String
Dim LExtension As String
Dim LContinue As Boolean
'Initialize variables
LContinue = True
LRow = 2
LPath = "C:\Users\Sophia\Downloads\New folder\"
LExtension = ".xl*"
'Loop through all column A values until a blank cell is found
While LContinue
'Found a blank cell, do not continue
If Len(Range("A" & CStr(LRow)).Value) = 0 Then
LContinue = False
'Check if file exists for part number
Else
'Place "No" in column B if the file does NOT exist
If Len(Dir(LPath & Range("A" & CStr(LRow)).Value & LExtension)) = 0 Then
Range("B" & CStr(LRow)).Value = "No"
'Place "Yes" in column B if the file does exist
Else
Range("B" & CStr(LRow)).Value = "Yes"
End If
End If
LRow = LRow + 1
Wend
End Sub