+ Reply to Thread
Results 1 to 8 of 8

runing macro depending on day

  1. #1
    Registered User
    Join Date
    01-07-2013
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    14

    runing macro depending on day

    Hi have written 7 macros that update a number of workbooks, ecah macro is for each differnt day,

    What I want is a macro thats on a button on sheet1 that when pressed will look at that date and then run that day's macro, this means the user can't hit the wrong the wrong button and update Thursdays information on Saturday for example! I have tried a couple but they don't work!

    Any ideas?

    Thanks for any help

  2. #2
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: runing macro depending on day

    Greetings

    The problem definition is a little loose.
    However you could do a check like:
    Please Login or Register  to view this content.
    coupled with a case statement, corresponding to your different daily macros to run. Then the macros would run when pressing 1 button instead of pressing other command control buttons.

    Regards

  3. #3
    Registered User
    Join Date
    01-07-2013
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: runing macro depending on day

    i should explain im really new at vba and strugling a bit, i have search case statments on the internet but im unsure how to tie it in, would this work
    say in cell A1 i have
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    if i did this all the way to 7 were 1=sunday 2=monday would this work?

    i appologise if what i have just wrote is as usefull as a chocolate firegarud but like i say i am new at this!

  4. #4
    Registered User
    Join Date
    01-07-2013
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: runing macro depending on day

    iv just been reading some more and wonderd if this was correct

    a1 is still

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit - Win 11
    Posts
    917

    Re: runing macro depending on day

    Something like this to get you going:
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: runing macro depending on day

    Hello
    Some good progress made, now just couple the items together, i.e. :
    Please Login or Register  to view this content.
    You just need to make sure the names of the 7 macros as the same as in your case statement. To test, you need to create {sub sunday() end sub} for each one otherwise VBA will complain

  7. #7
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: runing macro depending on day

    Hello
    Some good progress made, now just couple the items together, i.e. :
    Please Login or Register  to view this content.
    You just need to make sure the names of the 7 macros as the same as in your case statement. To test, you need to create {sub sunday() end sub} for each one otherwise VBA will complain.
    Also I had to change the function to "NOW" instead of today() as VBA does not seem to recognise "TODAY"

  8. #8
    Registered User
    Join Date
    01-07-2013
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: runing macro depending on day

    Works a treat now, Evan managed to modify it for other use's!

+ 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