How to link a macro by clicking on a cell of an Excel sheet

5 pts.
Tags:
Microsoft Excel
Microsoft Excel 2003
Microsoft Excel macros
I need to get the current time by clicking on the cell in Excel.

Answer Wiki

Thanks. We'll let you know when a new response is added.

You don’t need a macro:
In the cell type “=now()” (without quotes) and this will give u the date and time. It will also update.

If you are looking for macro:

Sub ShowTime()
ActiveCell.FormulaR1C1 = "=NOW()"
End sub

And then assign the macro to a button or menu item.

Hope this helps!

-Schmidtw

Schmidtw answerd very clearly. The only thing I may add is:
NOW() provides date & time. If you need only the time then Format the cell accordingly – h:mm AM/PM; h:mm; h:mm:ss , etc, (Excel 2007).
Good luck & enjoy Excel- ing!!!

The answer sounds good but there is catch here… Everytime you open the workbook it will refresh the book with new time…

Sub ShowTime()
Dim i, j

i = ActiveCell.Row
j = ActiveCell.Column

ActiveSheet.Cells(i, j) = Time
End sub

Regards,
Sarfaraz ahmed

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following