+ Reply to Thread
Results 1 to 14 of 14

Macro: check today date with start date and open a file in stored location

  1. #1
    Registered User
    Join Date
    10-16-2014
    Location
    Republic Czech
    MS-Off Ver
    Czech
    Posts
    32

    Post Macro: check today date with start date and open a file in stored location

    Hi all,

    I would like to kindly ask you if someone of you could help me to create a marco for the next.

    I have a classic table (see attached addition) where is written start date/duration/forecast/completion/status.
    I would like that the marco after open my excel file will always check the today date and compare it with start date. In case that this two dates will match it will automaticaly open a file in the location of my computer: C:\Users\tdubois\Documents . This macro should be able to open more files which are stored in the same location in case that today date will match with more start dates.

    Thank you for all your help.

    Regards
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Macro: check today date with start date and open a file in stored location

    you are missing the file names in table

    Kind regards
    Leo

  3. #3
    Registered User
    Join Date
    10-16-2014
    Location
    Republic Czech
    MS-Off Ver
    Czech
    Posts
    32

    Re: Macro: check today date with start date and open a file in stored location

    I have updated the table with name of the file. Now the location is as follow.
    C:\Users\tdubois\Documents\Test

    Thank you

    Regards
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Macro: check today date with start date and open a file in stored location

    something like this

    Please Login or Register  to view this content.
    Kind regards
    Leo
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-16-2014
    Location
    Republic Czech
    MS-Off Ver
    Czech
    Posts
    32

    Re: Macro: check today date with start date and open a file in stored location

    Hi Leo,

    I think it will works, but what should I modify in case that I want to change the storage location of my files from C:\Users\tdubois\Documents\Test for example to C:\Users\tdubois\Documents\SAP.

    Private Sub Workbook_Open()
    Application.ScreenUpdating = False
    With Sheets("Time")
    lastrow = .Range("B" & Rows.Count).End(xlUp).Row
    For x = 80 To lastrow Step 2
    If .Range("B" & x).Value = Date Then
    mylen = Len(.Range("Q" & x))
    mystart = Application.Search("C:\", .Range("Q" & x))
    myfile = Mid(.Range("Q" & x), mystart, mylen - (mystart - 1))
    Workbooks.Open (myfile)
    End If
    Next
    Application.Goto .Range("B" & lastrow), scroll:=False
    End With
    Application.ScreenUpdating = True
    End Sub

    Thank you for your great help.

    Regards,

  6. #6
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Macro: check today date with start date and open a file in stored location

    Hi Topa2,

    like it is now the code search for the file in merged columns "Q:Y"
    that was also the reasen for asking the file name in my first reaction.
    so without seperate column for the filename simpel change test to SAP in merged columns.

    Kind regards
    Leo

  7. #7
    Registered User
    Join Date
    10-16-2014
    Location
    Republic Czech
    MS-Off Ver
    Czech
    Posts
    32

    Re: Macro: check today date with start date and open a file in stored location

    Thank´s for your explanation.
    In your file the code is working well but when I copy your code into the original file (which I uploaded here) is not working. Can you tell me what could be a issue?

    Thank´s

    Regards
    Last edited by Topa2; 04-04-2016 at 08:42 AM. Reason: missing words

  8. #8
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Macro: check today date with start date and open a file in stored location

    No, I have to see the file

    Kind regards
    Leo

  9. #9
    Registered User
    Join Date
    10-16-2014
    Location
    Republic Czech
    MS-Off Ver
    Czech
    Posts
    32

    Re: Macro: check today date with start date and open a file in stored location

    Hi Leo,

    I tested your marco yesterday evening and it worked well. Thank you once again for your help!

    I would like to ask you one more thing. Is it possible to create a marco with the same way as you have done it means that it will check today date compare it with the starting date and if these dates are matching it will open a file from the storage location? The thing is that the files doesn´t have the same method of naming as those are different working formular.

    Thank you

    Regards,

  10. #10
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Macro: check today date with start date and open a file in stored location

    It is possible but the code has to know the name of the path and the name of the file.

    Kind regards
    Leo

  11. #11
    Registered User
    Join Date
    10-16-2014
    Location
    Republic Czech
    MS-Off Ver
    Czech
    Posts
    32

    Re: Macro: check today date with start date and open a file in stored location

    So, please could you please help me with this?
    You can use the same excel file as yesterday with the same storage location just the file name will be FQU770B. But I do not want to specify the path in my table. I would like to keep it just in the macro. As I´m using something around the 20 different file can you just explain to me if I can include all the name after in your code or how should I proceed in order to allow to your macro to search the different files following the starting date.

    Thank you

    Regards,

  12. #12
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Macro: check today date with start date and open a file in stored location

    change this
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Kind regards
    Leo

  13. #13
    Registered User
    Join Date
    10-16-2014
    Location
    Republic Czech
    MS-Off Ver
    Czech
    Posts
    32

    Re: Macro: check today date with start date and open a file in stored location

    Hi Leo,

    Sorry to disturb you again.
    I tried to modify your code but without success. I have attached the same file juste with different name of two files which I need to automatically open. Some of the file can have the same starting date and some another can have a starting date different.
    I would like to understand how to define in your code specification of each file linked to different starting date as after that I will be able to adjust it (maybe) allone .

    Thank you once again

    Regards,
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Macro: check today date with start date and open a file in stored location

    Please Login or Register  to view this content.
    Kind regards
    Leo

+ 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] Error check for Start date & End date in a macro
    By kmahesh in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-27-2014, 05:21 AM
  2. [SOLVED] On file open, automatically scroll to today's date
    By Tony Valko in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-28-2013, 04:13 PM
  3. How to get macro to open file name based on today's date?
    By ytc1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-05-2013, 05:37 AM
  4. [SOLVED] Open a batch file from the location where the worksheet is stored
    By grid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-20-2013, 01:38 PM
  5. [SOLVED] save currently open file appended with today's date
    By roothog in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-05-2011, 10:41 PM
  6. save file with today's date at a specific location
    By rajasekhar28 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-30-2009, 06:01 PM
  7. [SOLVED] Open an Excel file with a date as today in a macro
    By Perry in forum Excel General
    Replies: 4
    Last Post: 11-10-2005, 06:00 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