Macro that records the time it was used

WarriorJ

New Member
Joined
Jan 6, 2014
Messages
9
So here is the situation,

I have a macro for changing a cell's fill color when a button is clicked. I would like the macro to record the date/time it was used on each cell in a corresponding cell on a separate sheet. In other words, If the button is clicked, I want a time stamp in a cell on a different sheet. That cell must correspond with the cell modified by the macro. Below is the current VB code for the macro. Any help would be greatly appreciated.


Sub highlightgreen()
' highlights the current cell in green to denote passage through inspection device
' Keyboard Shortcut: Ctrl+g
ActiveSheet.Unprotect Password:="wouldntyouliketoknow"
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveSheet.Protect Password:="wouldntyouliketoknow"
End Sub

I thought of using a time stamp code similar to the one below (which I used in a different workbook). But I'm not sure how to implement it.

Sub timestart()
With ActiveCell
.Value = Time
ActiveCell.Offset(0, 1).Range("A1").Select
End With
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,213,521
Messages
6,114,109
Members
448,548
Latest member
harryls

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