the more i look at this the more i can see issues moving forward
its always going to hiccup when some sort of naming issues pops up
if you accidentally put a pdf in that folder that shouldnt be there
so
If j = 4 Then
On Error Resume Next
InvNum = Mid(strFileName, pos + 2) 'inv num - date.pdf
Cells(i, 4).Value = DateValue(Trim(Replace(Right(InvNum, Len(InvNum) - InStr(InvNum, "-") - 1), ".pdf", ""))) 'Date minus the .pdf
Cells(i, 3).Value = Left(InvNum, InStr(InvNum, "-") - 1) 'extract Inv Num
ElseIf j = 3 Then
On Error Resume Next
Cells(i, 4).Value = DateValue(Replace(Mid(strFileName, pos + 2, Len(strFileName)), ".pdf", ""))
End If
i think your best option is to put an on error resume code in there so it just skips the issue file
it wont fix it but you if you cant control the file names of the pdf this is the next best thing
also it seems case is a problem for you
so amending the search term
strSearch = UCase(Range("B4").Value) 'search term
Do While strFileName <> vbNullString 'loop for filenames in folder
If InStr(UCase(strFileName), UCase(strSearch)) > 0 Then 'if search term found in filename then go ahead
should help that
mind you if you just search for p d o r F
it will return everything because...well .pdf
Bookmarks