+ Reply to Thread
Results 1 to 4 of 4

VBA Script to open a specific File adn activate a specific sheet within that sheet.

  1. #1
    Forum Contributor
    Join Date
    09-05-2011
    Location
    Essex, England
    MS-Off Ver
    Excel 2003 Excel 2007
    Posts
    383

    Wink VBA Script to open a specific File adn activate a specific sheet within that sheet.

    Hi,

    I am looking for a script that when run would look for the date of the previous working day, and from this open a specific excel file from a single directory.

    all the files are named in a MMM YYYY.xls format i.e. JUL 2013.xls, within each of these workboots are 31 sheets one for each (potential) day of the month.

    So if the previous working day was the 21st of June 2013, the script would open JUN 2013.xls and activate the sheet named 21, and then run another function (that i've already written).

    Thanks in advance.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Script to open a specific File adn activate a specific sheet within that sheet.

    Have you an algorithm for the previous working day or is that information given?
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    09-05-2011
    Location
    Essex, England
    MS-Off Ver
    Excel 2003 Excel 2007
    Posts
    383

    Re: VBA Script to open a specific File adn activate a specific sheet within that sheet.

    I have been tinkering with this and have come up with the following:

    In sheet 1 cell D5 I have the the formula: ="S:\Folder\"&TEXT(MONTH(WORKDAY(TODAY(),-1))*29,"MMM")&" "&YEAR(WORKDAY(TODAY(),-1))&".xls"

    and in Cell D7 I have =DAY(WORKDAY(TODAY(),-1))

    and in my script I have:

    Please Login or Register  to view this content.
    Is this the best/most efficient method?

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA Script to open a specific File adn activate a specific sheet within that sheet.

    If it works, it's a good as any that I could come up with - nicely done

    But, doesn't the open statement need to be like this?

    Please Login or Register  to view this content.
    Last edited by xladept; 07-05-2013 at 01:48 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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