2

I need it to automatically grab the value of current time at a particular moment when the user does a specific action (like pressing a button maybe). The thing is, I need it to keep that value of time and not continue to update is as it generates new registrys in the rows below it.

What I'm trying to get is an Excel workbook that logs and keeps track of the time that my employees get to work, reason for which I dont want the user inputing the value of time but rather just pressing a button in a user form and the computer automatically generating and storing that data for later use by the admin.

The problem is that the Now() function always updates to the current time.

Help is appreciated!

Hennes
  • 65,142

2 Answers2

1

Make File->Option->Formulas->Calculation options as Manual

1

That is the function of now(), to give the current time.

What you need is some simple VBA to return the current date/time when a button is pressed.

You don't say what version of Excel. For 2010/2013 you will need to turn on the Developer tab in the Ribbon and ensure that you set Excel to allow running macro's.

From the developer tab, inset a "Button (Form Control)". Give it a new Macro to work with.

Put in the following code:

Sub Button1_Click()
    Application.ActiveCell.Value = Now()
End Sub

It inserts the current date/time as a fixed value in the currently selected cell.

Julian Knight
  • 14,501
  • 3
  • 29
  • 44