Run a macro in active cell only. Want to place current date/time.

T

time clock watcher

Would like to make a Gate sign in sheet with a macro named ("GateIN") that
will return the current date/time in the active cell only. When the same
macro is run in an other cell I'd like the later current time to be entered
but leave the previous cell un-touched.
 
S

stanleydgromjr

time clock watcher,

PLEASE TEST THIS FIRST IN A COPY OF YOUR WORKBOOK (ALWAYS MAKE A BACKUP
COPY BEFORE TRYING NEW CODE, YOU NEVER KNOW WHAT YOU MIGHT LOSE).

Adding the Macro
1. Copy the below macro, by highlighting the macro code and pressing
the keys CTRL+C
2. Open your workbook
3. Press the keys ALT+F11 to open the Visual Basic Editor
4. Press the keys ALT+I to activate the Insert menu
5. Press M to insert a Standard Module
6. Paste the code by pressing the keys CTRL+V
7. Press the keys ALT+Q to exit the Editor, and return to Excel.


Code:
--------------------


Sub GateIN()
With ActiveCell
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm AM/PM"
End With
End Sub


--------------------



Then run the "GateIN" macro.


Have a great day,
Stan
 
S

Simon Lloyd

You probably want thi

Code
-------------------
Sub GateIN(
If ActiveCell = "" The
ActiveCell.Value = No
Els
ActiveCell.Offset(0, 1).Value = No
End I
End Su

-------------------
Luke said:
Sub GateIN(
ActiveCell.value = No
End su
-
Best Regards

Luke
*Remember to click "yes" if this post helped you!

--
Simon Lloy

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top