code to caputre time in vb in a specific cell

  • Thread starter Thread starter JTS
  • Start date Start date
J

JTS

I am starting to use macros in Excel and need help trying to find the visual
basic code (also new at vb) to capure time. I need to start time and finish
time when wroking in Excel to time I sepend completing one form.
JTS
 
You will need some sort of event to capture the start time and ending time.
I chose the Workbook Open event to capture the start time and BeforeSave
event to capture the ending time. Place this code below in the ThisWorkbook
Module. When you save the workbook a message box will appear telling you the
time it took to fill the form out.

Option Explicit

Dim StartTime As Date
Dim EndTime As Date

Private Sub Workbook_Open()

StartTime = Format(Now, "hh:mm:ss")

End Sub

Private Sub Workbook_BeforeSave()

EndTime = Format(Now, "hh:mm:ss")
MsgBox "Time Elasped = " & Format(EndTime - StartTime, "hh:mm:ss")

End Sub

Hope this helps! If so please click Yes below.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top