+ Reply to Thread
Results 1 to 11 of 11

Is it possible??? Using Excel to search files on a desktop folder

  1. #1
    Registered User
    Join Date
    11-19-2014
    Location
    Gatineau, Quebec
    MS-Off Ver
    2010
    Posts
    27

    Is it possible??? Using Excel to search files on a desktop folder

    Good morning,

    This is a good one and I'm not even sure if it's possible... Solving this issue would really make year!!!! not kidding.

    Here's my issue, I'm working with one main Excel file for the whole fiscal year. This file is mainly used to track paid and unpaid invoices. (Column D = invoice #)

    Considering that all the PDF invoices are saved in a main folder (each PDF files name are the invoice # mentionned in column D), is there a way or a formula that Excel could seach in the invoice folder and insert "yes" if the invoice is available in that fodler?

    Thanks in advance

    Dan

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Is it possible??? Using Excel to search files on a desktop folder

    Create a UDF using a small piece of VBA

    https://www.google.co.uk/?gws_rd=ssl...el+file+exists
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    11-19-2014
    Location
    Gatineau, Quebec
    MS-Off Ver
    2010
    Posts
    27

    Re: Is it possible??? Using Excel to search files on a desktop folder

    thanks for your help, but I'm familiar enough with VBA, but I will try to figured-it out

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Is it possible??? Using Excel to search files on a desktop folder

    You gave only a general description of your problem, so you are getting a general answer.

    If you attach your file, give the full path name that contains the invoice files, and give the exact format of the PDF file names, then we can give you specific code for your situation.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  5. #5
    Registered User
    Join Date
    11-19-2014
    Location
    Gatineau, Quebec
    MS-Off Ver
    2010
    Posts
    27

    Re: Is it possible??? Using Excel to search files on a desktop folder

    my bad, herE's the file and here's my path

    U:\2016 - 2017

    Thanks in advance
    Attached Files Attached Files

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Is it possible??? Using Excel to search files on a desktop folder

    Here is a solution using a UDF called InvoiceFileExists. The values you see are leftover from my test--I do not have a U drive. If they do not automatically refresh to match your environment, you may need to force them to recalculate.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-19-2014
    Location
    Gatineau, Quebec
    MS-Off Ver
    2010
    Posts
    27

    Re: Is it possible??? Using Excel to search files on a desktop folder

    as recommended, I will ask you another question here.

    I have tried to copy/paste your VB Code into a different spreadsheet because I want to do the same thing and the path is in red.¸

    Is it possible to simply copy/paste your coding into another spreadeet?

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Is it possible??? Using Excel to search files on a desktop folder

    Quote Originally Posted by philion_91 View Post
    the path is in red.
    Do you mean this line of code is red:

    Please Login or Register  to view this content.
    That indicates a syntax error, but should not happen if you are simply copying and pasting the entire code. Are you sure you didn't delete a character in the process by accident?

    You can copy all the code from the new location and paste it here for review. In this case even a screenshot would be OK, although that would take you more steps.

  9. #9
    Registered User
    Join Date
    11-19-2014
    Location
    Gatineau, Quebec
    MS-Off Ver
    2010
    Posts
    27

    Re: Is it possible??? Using Excel to search files on a desktop folder

    The first print screen is from the file that you have provided me with (worksvery well)

    The second print screen is the error message that I got after I copied-pasted the coding into a different spreadsheet.

    3th prin screet is the pasted cosing

    Public Const pathroot As String = "U:\FAS-SFA\CAANCS-CAMSRN\CA-CM\NAS-SCAC\COMPTES PAYABLES\OGD\2016 - 2017\Invoices Only\"

    Finnally, the 4th print screen is the formula that I have recreated for your the invoice #.
    Attached Images Attached Images

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Is it possible??? Using Excel to search files on a desktop folder

    The error message says what's wrong. My code was in Module1 but you pasted it into a Worksheet module. You cannot have a Public Const in a Worksheet module. Fortunately, it doesn't need to be Public. You can just delete the word Public in the Const declaration and you should be ready to go.

  11. #11
    Registered User
    Join Date
    11-19-2014
    Location
    Gatineau, Quebec
    MS-Off Ver
    2010
    Posts
    27

    Re: Is it possible??? Using Excel to search files on a desktop folder

    nice, the path is correct no, but unfortunately there's another thing.

    I'm still getting an error instead in column L, where I have added formula =InvoiceFileExists(D2)

    Do you know why?

    Once again, thanks for your help and your patience, I really want this to work and unfortunately, there's nobody around to help me with VB.
    Attached Images Attached Images

+ 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. [SOLVED] VBA to rename PDF files saved in Desktop folder using excel 2010
    By Chandrahaas in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 09-08-2022, 09:27 AM
  2. [SOLVED] Excel VBA code for selecting a folder then search & open specified files in that folder
    By Excelrookie_1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2021, 03:09 AM
  3. [SOLVED] Macro to open folder on desktop and certain files within
    By hutch94 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-05-2014, 11:01 AM
  4. Search for a string on all excel files inside a ZIp folder
    By Moreno20 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2014, 03:45 PM
  5. Search folder for excel files.
    By endoskeleton in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-27-2011, 03:31 PM
  6. Case insensitive search for string within folder of excel files
    By vba_novice in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-22-2011, 11:21 PM
  7. Search folder for all excel files
    By Schwizer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2007, 03:24 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