+ Reply to Thread
Results 1 to 5 of 5

cell value from 6 to 14 then

  1. #1
    Forum Contributor
    Join Date
    09-08-2009
    Location
    Norway
    MS-Off Ver
    Excel 2002
    Posts
    142

    cell value from 6 to 14 then

    Ok so i'm trying to write a small macro which will initiate my code on a day of the month, at a specified time of the day the macro will change, according to the different shifts we work here.

    what i want it to do is to run the macro Formiddag1 when time time of the day is between 6 to 14

    I already have my worksheet set up with =Today() and =Now() Formula's to get the specific time, so the cells they are pointing to contain the correct values and they update whenever the day changes, and the hour changes. I guess i could write it to Change the Macro to run at 6 only but it would be nice to have the code know to run the code in question if the time of day is between 6-14 , the code will run approx. every 15 minutes.

    here is the code i have so far;

    Please Login or Register  to view this content.
    Last edited by prefix; 11-18-2010 at 02:52 AM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: cell value from 6 to 14 then

    So you only want to run the macro if the workbook is opened between 6am and 2pm and then run it every 15 mins?

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: cell value from 6 to 14 then

    Good morning prefix

    I think you're going about it the wrong way, to put the time in a cell, and then test that. Use code like this to test the hour, and react to it :
    Please Login or Register  to view this content.
    With regard to running the code every 15 minutes have a look at Chip Pearson's article on using OnTime here.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Forum Contributor
    Join Date
    09-08-2009
    Location
    Norway
    MS-Off Ver
    Excel 2002
    Posts
    142

    Re: cell value from 6 to 14 then

    Nice, i'll test that out, i didn't know the correct VBA so i figured i would use formula's together with Cells.Value, As for the 15 minute updater i already have a code for that, i just need a code to change between the macro's for each day and the 3 shifts on each day.
    This is what this is for Thanks

  5. #5
    Forum Contributor
    Join Date
    09-08-2009
    Location
    Norway
    MS-Off Ver
    Excel 2002
    Posts
    142

    Re: cell value from 6 to 14 then

    Edited out, moved it to a thread of its own.
    Last edited by prefix; 11-18-2010 at 02:52 AM.

+ 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