+ Reply to Thread
Results 1 to 33 of 33

Search for pdf files by date or title

Hybrid View

  1. #1
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Search for pdf files by date or title

    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
    Attached Files Attached Files
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. many workbooks title into cell after search
    By mrjackt in forum Excel General
    Replies: 0
    Last Post: 03-05-2015, 08:58 AM
  2. Need to search array and return value along with title and row values
    By wilburr in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-28-2013, 06:01 AM
  3. [SOLVED] Search files until date is found
    By twckfa16 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2013, 02:57 PM
  4. Using cell contents to search for corresponding sheet title
    By teblowtime in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-30-2013, 03:31 PM
  5. Replies: 3
    Last Post: 04-08-2012, 06:52 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1