+ Reply to Thread
Results 1 to 1 of 1

Thread: pass arguments to "Application.OnTime" event?

  1. #1
    Forum Contributor wamp's Avatar
    Join Date
    11-10-2008
    Location
    Norway
    MS-Off Ver
    97, 2000 & 2003 (diff. workstations)
    Posts
    184

    pass arguments to "Application.OnTime" event?

    in short: is it possible to pass arguments to an OnTime event?

    I have a list of different timevalues (hh:mm)
    I am trying to create alarms based on those values; while passing an arguement (for examle the rownumber of the processed cell)

    for each cell in sheetname.range("A1:A10") ' all these cells contain different hh:mm values
    if (cell.value - timevalue("00:15:00"))  > TimeValue(Now) then
    'say the time now is 10:00 ; then the next bit of code will execute if the cellvalue = 10:16 or higher
    'so far so good..  now
    
    
    'if I try this (passing an argument to a function):
    Application.OnTime (cell.Value) - TimeValue("00:15:00"), alarm(cell.row)
    'it will immediately execute the "alarm" function. (passing the argument)
    
    'if I try this however (not passing any arguments, just calling a macro named "alarm"):
    Application.OnTime(cell.value) - TimeValue("00:15:00"),alarm
    'it will run the "alarm" macro -when- the ontime-value is correct
    
    end if
    next cell
    is there any way around this?
    The only thing I can think of right now, is perhaps storing the cell.row in a public array that the macro reads upon execution..

    My purpouse of passing the cellrow by the way, is to create an alarm that shows different values of different cells in that particular row.
    for instance
    msgbox("remember to do: " & sheetname.range( "x" & cvalue ).value)

    EDIT
    Found the solution here

    the correcto code would for example be (a lot of commas in the passing argument)
    Application.OnTime Now + TimeValue("00:00:02"), "'alarm cell.row'"
    Last edited by wamp; 09-06-2010 at 06:32 AM. Reason: found solution
    _______________________________________________
    Remember:

    Read the rules!

    Use code tags! Place [CODE] before the first line of code and [/CODE] after the last line of code.

    Mark your post [SOLVED] if it has been answered satisfactorily.
    To do this, click EDIT in your original post, click GO ADVANCED and set the PREFIX. It helps everybody!

    If you are approve (or disapprove) of any members response to your problem, please click the star icon underneath their post and comment. It matters.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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.2.0