Creating An Audit Log

drmingle

Board Regular
Joined
Oct 5, 2009
Messages
229
I am trying to get this code to spit out the data in a cell within the same workbook but a different worksheet --> Sheet ("SpeedLog") instead of the message box.

The time element works fine within the routine, but I need help converting from a message box to a value in a cell:
Code:
MsgBox "This CVTY Speed Search was completed in" & " " & (DateDiff("s", start_time, end_time)) & " " & "seconds."

In addition, I only the time not the commentary:
Code:
(DateDiff("s", start_time, end_time))

Lastly, I am trying to use this other code snippet to be sure I fill the next cell which is empty with only the calculated data:

I think this should work
Code:
Sheets("SpeedLog").Activate
Sheets("SpeedLog.Range("C1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

Any thoughts would be appreciated...
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Code:
sheets("Speedlog").range("A1").value =  "This CVTY Speed Search was completed in" & " " & (DateDiff("s", start_time, end_time)) & " " & "seconds."

or

Code:
sheets("Speedlog").range("A1").value = DateDiff("s", start_time, end_time)

if your trying to get this same value into the next empty cell then:

Sheets("SpeedLog").Range("C1").End(xlDown).Offset(1, 0).value = DateDiff("s", start_time, end_time)
 
Last edited:
Upvote 0
I'm getting a run-time error of 1004

on the code you posted --> Application-defined or Object-defined error

Any ideas??
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,823
Members
449,470
Latest member
Subhash Chand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top