+ Reply to Thread
Results 1 to 4 of 4

Need to run macro automatically once every week

  1. #1
    Registered User
    Join Date
    10-03-2011
    Location
    Venlo, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    3

    Need to run macro automatically once every week

    Hi.

    We have an excel file that has a form with a button to "create a new database".
    This sheet is used by several people. And the first one to use the sheet any particular week needs to create the new database. Unfortunately the creation of this database can take up to an hour to run.

    Now they want to automatically have this macro run every Sunday evening.
    I can create a "scheduled task" on a server that opens the sheet on Sunday.
    But I have no idea how to program VB so that when the sheet is opened on any Sunday at say 10pm, that it will create this database automatically.

    Could somebody please help?

    What I need:
    - A macro that runs automatically when the file is opened on Sunday.
    - This macro needs to call the "creation of the database" function.
    - After this macro has run automatically it needs to close the sheet.

    A big THANK YOU if you are able to help.

    grtz,
    Twan

    P.S. This is the code from the form:
    Please Login or Register  to view this content.
    This is the code of the database creation:
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 10-03-2011 at 03:07 AM. Reason: Changed Quote Tags to Code Tags

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Need to run macro automatically once every week

    Je zult de gebeurtenis Workbook_open moeten gebruiken.

    You'll have to use the Workbook_open event.
    You can't use this code if user input is required (you didn't show what the result of userform2 will be).
    Looking at the code I think that with some slight alterations, the code won't take hours to produce a simple databases (A2:E5002) but only a minute. (not deleting formatting/formulas, but only replacing values in cells e.g., no using select/activate, screenupdating disabled, calcualtion disabled etc.)
    Last edited by snb; 10-03-2011 at 04:00 AM.



  3. #3
    Registered User
    Join Date
    10-03-2011
    Location
    Venlo, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Need to run macro automatically once every week

    Hi SNB.

    Thanx for your quick answer.
    I have not "written" this script myself, and the person that did is no longer available.
    If you can suggest a change to the script that will dramatically change the time needed to create a new database, we are very content with letting it up to the user to perform this manually, and no automated process is needed.

    What are your suggestions?

    To be complete, what do you mean with userform 2?

    grtz,
    Twan
    Last edited by TwanVeugelers; 10-03-2011 at 06:12 AM.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Need to run macro automatically once every week

    Please do not quote (see the forum rules).
    I sent you a PM.

    the frmoutput2 is a userform that requires a user to input some data.

+ 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