Senin, 15 Juli 2013

RE: [ExcelVBA] A simple uptime logging worksheet?

 

John,
I am not sure that I understand the question, but based on what I interpret the question to be, this will do it:

Add a command button ( Developer -> Insert -> select "Command Button" under "ActiveX Controls")

Private Sub CommandButton1_Click()
Range("A1").FormulaR1C1 = Now
Call WaitFor(5) 'for a delay of a minute
Range("A2").FormulaR1C1 = Now
ThisWorkbook.Save
Call WaitFor(5) 'for a delay of a minute
Range("A2").FormulaR1C1 = Now
ThisWorkbook.Save
End Sub

Sub WaitFor(NumOfSeconds As Long)
Dim SngSec As Long
SngSec = Timer + NumOfSeconds
Do While Timer < SngSec
DoEvents
Loop
End Sub

Tim

From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] On Behalf Of Dr John C Bullas
Sent: Monday, July 15, 2013 2:46 PM
To: excelvba@yahoogroups.com
Subject: [ExcelVBA] A simple uptime logging worksheet?

Good afternoon,

I am a newby as regards VB, I know what I want to achieve but I have no
real idea how to go about it. I want to leave a worksheet open that will
autosave to keep a record of the current time and when it was opened, thus
the uptime is recorded.....

=================

Sub WaitFor(NumOfSeconds As Long)
Dim SngSec as Long
SngSec=Timer + NumOfSeconds

Do while timer < sngsec
DoEvents
Loop

End sub

=============

Called up by

Call WaitFor()

i.e Call Waitfor(60) for a delay of a minute

====

I want to have a worksheet with a GO button that copies the value of NOW()
into A1 and then waits for a minute copies the value of NOW() into A2 then
saves the worksheet then waits for a minute then repeats the write of NOW()
to A2 and saves again

When this falls over I will have the uptime and the start and end times for
the period

Is this difficult to code?

--

===========================
http://uk.linkedin.com/in/drjohnbullas

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar