+ Reply to Thread
Results 1 to 2 of 2

Need code to check if file exists then activate conditional macro

  1. #1
    Registered User
    Join Date
    03-02-2013
    Location
    MT, US
    MS-Off Ver
    Excel 2003
    Posts
    3

    Need code to check if file exists then activate conditional macro

    Hello,

    I'm not sure how to pose this question because I don't know all of the proper terms / lingo, so I'll explain what Im trying to accomplish and cross my fingers someone can help.

    I am making a "dashboard" for our work computers. Not a dashboard to display stats, but a dashboard to organize file locations and display status updates to the user. My team works at remote terminals and often switch around covering different locations (where the computers are located). Im trying to make it so that when a team member walks into the remote office, they can see at a glance if certain work has been done already or not. To that end Im trying to figure out a way to have a conditional format option change based on if a file with a certain date exists in a folder. EG a daily report is done at every location, every day. The file is named DailyReport_1.3.14.xlsm (the date changes for each day). What I want to do is make a VBA code that will check to see the current date, and then check to see if a file with a matching date is located in the reports folder. One of the problems I foresee is that the reports are organized by yearly/monthly folders. IE ...\2014\January\DailyReport_1.2.14.xlsm. I dont know enough about VBA to know if you can search multiple folders (2014 Jan - Dec & 2015 Jan - Dec etc).

    My end goal is to have a little stoplight show red if that day's report has not been done, and show green if that day's report has been done.

    What I started with is this code...

    Please Login or Register  to view this content.
    So I guess the long and short of it is that I need to determine the current date, check to see if any file matches that date, and then affect a conditional macro based on the answer. Is this possible? Please keep in mind that I really am a novice with VBA (I didn't know what it was until earlier tonight). I have a pretty good working knowledge of Excel.

    Thanks so much in advance!

    Moderator's note: I have added code tags for you because you are new. Please take the time to review our rules. There aren't many, and they are all important.. See #3. --6SJ
    Last edited by 6StringJazzer; 01-03-2014 at 10:30 PM.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Need code to check if file exists then activate conditional macro

    Try this code instead of you FilePath line:
    Please Login or Register  to view this content.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

+ 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. VBA code to check #REF error exists in Excel file
    By KPK in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 10-02-2013, 01:56 AM
  2. Replies: 1
    Last Post: 05-29-2013, 01:20 PM
  3. Macro to check if file exists
    By mvsareli in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-16-2013, 04:51 PM
  4. Macro to check file exists and take input from the file
    By naidu9295 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-12-2010, 08:15 AM
  5. a macro code to check exists of name or text in sql database
    By abhay_547 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-18-2009, 12:16 AM

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