+ Reply to Thread
Results 1 to 12 of 12

Need code for changing workbook on time ?

  1. #1
    Registered User
    Join Date
    07-22-2013
    Location
    holland
    MS-Off Ver
    Excel 2007
    Posts
    20

    Need code for changing workbook on time ?

    Hi guys,

    Looking for a macro that if on suday my workbook is active that my workbook closes and saving my workbook and that a other workbook is opening at 13:00.

    Regards,
    Last edited by black7; 08-20-2013 at 12:37 PM.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: On sunday13:00

    Put this in the workbook or a worksheet module:
    Please Login or Register  to view this content.
    Place this in its own stand alone module:
    Please Login or Register  to view this content.
    Untested.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    07-22-2013
    Location
    holland
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: On sunday13:00

    The Code works almost. Lets give you more info because i think i set the code wrong because i am new to Macro scripting .

    My workbook names are TeamA and TeamB and the files are by me on s:\Teams\

    If i execute the macro SwitchWB the new workbook opens nice but the old workbook stays also active in the background ?

    Please Login or Register  to view this content.
    Last edited by black7; 08-20-2013 at 01:34 PM.

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Need code for changing workbook on time ?

    Please Login or Register  to view this content.
    Thats because when you open a workbook it becomes the activeworkbook. Thats why there are two workbook variables.

    e/ I just realized I forgot to Dim wb2 in my first code. My mistake.
    Last edited by Solus Rankin; 08-20-2013 at 02:25 PM.

  5. #5
    Registered User
    Join Date
    07-22-2013
    Location
    holland
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Need code for changing workbook on time ?

    Strange things happen. The first time i start the SwitchWB after editing it is working fine but the second time when i close every workbook and open TeamA workbook and start SwitchWB again the TeamB opens but also TeamA stays open and share the same workbook. What is wrong ?

  6. #6
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Need code for changing workbook on time ?

    Can you attach your workbooks?

  7. #7
    Registered User
    Join Date
    07-22-2013
    Location
    holland
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Need code for changing workbook on time ?

    I have also an macro with an timer function in my workbook that is activated when i open the workbook. If i turn the timer off it seems to work fine. I have also an Stop_timer macro. Can i put that in your macro so that first the timer stops and then the workbook is saved, open and closed ? On this post the files.

    Thanx.
    Attached Files Attached Files

  8. #8
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Need code for changing workbook on time ?

    I'm a little confused by that question. It looks like you already called the sub to stop the timer?

  9. #9
    Registered User
    Join Date
    07-22-2013
    Location
    holland
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Need code for changing workbook on time ?

    Forget that Stop_timer sorry i confused you. But can i put the Stop_timer in your macro or doesn't work that ? Because if the timer is on then it don't work

  10. #10
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Need code for changing workbook on time ?

    Possibly. Try: Attachment 259383

    Untested.

  11. #11
    Registered User
    Join Date
    07-22-2013
    Location
    holland
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Need code for changing workbook on time ?

    Yes, that did the trick. It is working fine now. Many thanx for helping me out so quickly.

  12. #12
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Need code for changing workbook on time ?

    Glad to help If you are happy with the solution please mark the thread as [SOLVED] using the thread tools at the top.

+ 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