Inserting a timestamp & datestamp help. :(

Hanz_Solo

New Member
Joined
Sep 12, 2012
Messages
3
Hello,

Im new to this forum and new to excel. I am trying to set up my doc. so that when i double click with in columns (B&C)) the current time get inserted in a 24hr format. I am also trying to do the same thing but with a date formula (column A, also with the double click feature) Any information would be extremely helpful.

Thank you and God bless,

-Justin
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi, and welcome to the board.
Right click your sheets tab and choose "View Code".
In the new window paste this VBA code in the right part of the "Visual Basic Editor" (white empty space),
and then close the "Visual Basic Editor".
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Column = 2 Or Target.Column = 3 Then
        Target.Value = Time
        Target.NumberFormat = "hh:mm:ss;@"
    ElseIf Target.Column = 1 Then
        Target.Value = Date
    End If
End Sub

Vidar
 
Last edited:
Upvote 0
You could also use Excel's build-in keyboard shortcuts for the data and time stamps.

Date stamp = Hold down the Ctrl key and press the ; (semicolon) key
Time stamp = Hold down both the Ctrl and Shift keys and press the ; (semicolon) key
 
Upvote 0
Vidar,

Thank you, the code works great. I have another question though. I am having trouble saving the doc. When I try to save it a message pops up saying

"The following features cannot be saved in macro-free workbooks ext."

Do you have any pointers on this subject. I'm trying to set it up so when I open the document the code and everthing is already set up and saved.


-Justin
 
Upvote 0
Allan,

Hello. I have been saving it as a "Macro-Enabled Workbook" but when I close the program and re-open it the code is not there anymore. I'm not sure what I'm missing.

-Justin
 
Upvote 0
Hi Justin

Do you se a yellow button below the "Ribbon" that says "Enable Content"?
The macro's in the workbook won't start until you click that button.

Vidar
 
Upvote 0

Forum statistics

Threads
1,215,669
Messages
6,126,117
Members
449,292
Latest member
Mario BR

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