+ Reply to Thread
Results 1 to 13 of 13

VBA code to save excel sheet twice a day

  1. #1
    Registered User
    Join Date
    01-06-2012
    Location
    kentucky
    MS-Off Ver
    Excel 2007
    Posts
    10

    VBA code to save excel sheet twice a day

    I currently have an excel workbook that saves individual sheets in a folder on a server.
    It saves it in a folder by the month and day.
    Currently it saves at 11;00 pm, what I would like it to do is to save at 4:00 am and again at 4:00 pm.
    I would need the 4:00 pm to be saved in a first shift folder and the 4:00 am in a second shift folder.

    If it would help I could post the code I am using now. Then maybe someone could guide me to what changes would need to be made.


    Thanks

  2. #2
    Registered User
    Join Date
    01-06-2012
    Location
    kentucky
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: VBA code to save excel sheet twice a day

    By the way I am working with excel 2002 on an older windows 2000 server

  3. #3
    Registered User
    Join Date
    04-19-2010
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: VBA code to save excel sheet twice a day

    Will the file be open the whole time?

    If that is the case you can put some Applicaion.Ontime statements together.

    Please Login or Register  to view this content.
    I am not to good with the application.ontime method though. Maybe someone else can pick up my slack!

  4. #4
    Registered User
    Join Date
    01-06-2012
    Location
    kentucky
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: VBA code to save excel sheet twice a day

    Yes, the excel workbook stays open all the time and is used as a data save.

    I will post my code, since I am not real familiar with VBA yet.
    This is code that was written by a coworker that no longer works here.

  5. #5
    Registered User
    Join Date
    01-06-2012
    Location
    kentucky
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: VBA code to save excel sheet twice a day

    Please note that there is alot of extra stuff in this that I have just noted or pseudo-coded out, in case I will need it for later use.

    If its possible please make the changes to the file and then repost it.
    This would better help me understand what would need to be done.

    Thanks

    This is the vba code that I have posted to the notepad
    VBA.txt

  6. #6
    Registered User
    Join Date
    01-06-2012
    Location
    kentucky
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: VBA code to save excel sheet twice a day

    Has anyone been able to look at the code I posted? I have tried a few different things but have not had any luck.
    I'm trying to learn VBA, I am still new to it.

    Any help would be appreciated.

    Thanks

  7. #7
    Registered User
    Join Date
    01-06-2012
    Location
    kentucky
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: VBA code to save excel sheet twice a day

    Is what I am wanting not possible?

  8. #8
    Registered User
    Join Date
    04-19-2010
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: VBA code to save excel sheet twice a day

    Are you having some error on that code, I'm thinking that pausing like that will tie up the system. I'm not sure though. If I get some time today I will do some looking on the onTime events. (I'd like to learn them myself)

  9. #9
    Registered User
    Join Date
    01-06-2012
    Location
    kentucky
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: VBA code to save excel sheet twice a day

    Quote Originally Posted by Bmoe View Post
    Are you having some error on that code, I'm thinking that pausing like that will tie up the system. I'm not sure though. If I get some time today I will do some looking on the onTime events. (I'd like to learn them myself)
    Yes at certain times the macro will have an error saving a file and stop working. This causes the data not to be saved way before a shift ends.

    All, I need it to do is too save the file at 4:00 am and again at 4:00 pm.
    I have bought a book about VBA, hopefully it will help as I move forward understanding VBA.

  10. #10
    Registered User
    Join Date
    01-06-2012
    Location
    kentucky
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: VBA code to save excel sheet twice a day

    Quote Originally Posted by Bmoe View Post
    Are you having some error on that code, I'm thinking that pausing like that will tie up the system. I'm not sure though. If I get some time today I will do some looking on the onTime events. (I'd like to learn them myself)
    Thanks for taking the time to look at it.

  11. #11
    Registered User
    Join Date
    01-06-2012
    Location
    kentucky
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: VBA code to save excel sheet twice a day

    Is there any services people can recommend, where I can just pay someone to write VBA macro's for me?

  12. #12
    Registered User
    Join Date
    01-15-2010
    Location
    VA, USA
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: VBA code to save excel sheet twice a day

    Yes there are services like that and I sent you a private message. Basically what you need to do is create an event in this specific file and then have 2 subroutines that are called at specific times(there are multiple ways to do it actually). Each one saving to a different location depending on the time. If you put your code on this page I will look into further since I think this is easily done. It is considered more appropriate to put the code on the website as opposed to saving it to a text file as you did above. Use the:
    ['code]
    your code here ...
    and here ...
    and here
    [/code]
    **Note Remove the ' from ['code]

  13. #13
    Registered User
    Join Date
    01-06-2012
    Location
    kentucky
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: VBA code to save excel sheet twice a day

    Quote Originally Posted by vthokie2010 View Post
    Yes there are services like that and I sent you a private message. Basically what you need to do is create an event in this specific file and then have 2 subroutines that are called at specific times(there are multiple ways to do it actually). Each one saving to a different location depending on the time. If you put your code on this page I will look into further since I think this is easily done. It is considered more appropriate to put the code on the website as opposed to saving it to a text file as you did above. Use the:
    ['code]
    your code here ...
    and here ...
    and here
    [/code]
    **Note Remove the ' from ['code]
    I tried to post the code like that but it said that it was too many characters.

+ 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