Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need Help with executing a function based on time.

I have an application were I need to save the data in a
spreadsheet two times a day at specifc times. I need to
save them off as differnt name+date+time. My problem is
that when I do a comparison on the time, it executes the
function (msg boxs indicator) but the it doesnt create
the file. If I execute this with a button on the screen,
it will work everytime.
My Goal : I have some live data (DDE values) that I need
to save off in a static file of sometype, maybe there is
another solution that I havent considered, any
suggestions are thankfully welcomed.
-----------------------------------------
Execution command in a cell.
=IF(D80=E80,autosave(),"NOT RUNNING")
-----------------------------------------
Converting time value to a number for
the comparsion
=TIMEVALUE(D81)
=TIMEVALUE(E81)
-----------------------------------------
Function autosave()

Dim strdate As String
strdate = Format(Date, "ddd, mm dd yyyy")
ActiveWorkbook.SaveCopyAs Filename:="C:\temp\Myreport " &
strdate & ".xls"
MsgBox "Report Has Run"
End Function
------------------------------------------
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need Help with executing a function based on time.


Hi

Have you tried the OnTime event of the application class? In you
situation, if I have understood your requirement, what you can do i
write an OnTime event procedure - the code that you have is pretty muc
ok (I don't believe that there might be a need for comparing times sinc
you can specify the time &/or schedule in the OnTime event procedures).

With that in place, the code should run at your nominated time and o
your nominated schedule! I haven't used the schedule bit but if you d
not want to try that, you may want to write 2 separate OnTime event
for the 2 times that you may be interested in!

This is on the presumption that your spreadsheet is always open at th
scheduled times.

This could get a bit tricky in that the copy of the spreadsheet tha
has got saved will also have this event in it - you may want t
consider manually removing the event from the saved copy.

See "http://www.cpearson.com/excel/vbe.htm" on how to remove VB
procedures/modules for workbooks. You may want to consider includin
some of those code to remove this event from the saved copy.


Hope this helps!

Best regards


Deepak Agarwa

--
agarwaldv
-----------------------------------------------------------------------
agarwaldvk's Profile: http://www.excelforum.com/member.php...fo&userid=1134
View this thread: http://www.excelforum.com/showthread.php?threadid=26665

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I stop a formula from executing based on a cell value? Ricke New Users to Excel 4 October 5th 08 09:39 PM
executing a function? Ray Excel Discussion (Misc queries) 2 March 24th 07 07:37 PM
Executing a formula based on criteria being met confused teacher Excel Worksheet Functions 2 August 17th 06 06:56 AM
code sample for executing a VB function in Excel using perl newOLE Excel Worksheet Functions 7 August 10th 05 10:26 PM
Executing code based on changes made to a form ? Dan Thompson Excel Programming 1 September 29th 04 06:51 PM


All times are GMT +1. The time now is 07:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"