View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
George Applegate
 
Posts: n/a
Default NOW function question

Ardus,

I tried this and it didn't work so I must be doing something wrong,
but what???

I right clicked the excel icon, and then selected "view code"
It brings up a box that says "Book1- this workbook(code)
and then has scroll boxes that say "general" and "declarations".

When I copy/paste the code you supplied the "private sub..." shows in
red, the "range..." shows in black, and the "end sub" shows in blue.

On the left side there is another window which says "project vba
project" and then it has "vba project book 1" and then has "microsoft
excel objects", with subs sheet 1, sheet 2, and sheet 3 and then "this
workbook". "this workbook" is highlighted.

I enter the code you gave, and close the "x" in the right hand corner.

I save the worksheet but I don't see it doing anything in cell a1. I
close it/reopen it, and still nothing is displayed. Yet if I
right-click on the excel icon again, it still shows the code snippet I
pasted.

Is something wrong since the "private sub..." code is shown in red???

This is exactly what I want if you can help me figure out what I am
doing wrong in the entry, or point me to another place where I can see
a live example or something.

THANKS SO MUCH IN ADVANCE FOR YOUR HELP!!
ga

"Ardus Petus" wrote:

Assuming you want the timestamp in cell A1,

Right click on the Excel icon on top left corner of your worbook's window
Select Code
Paste the following:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Range("A1") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End Sub

Get back to Excel
Save your workbook

Et voilą!


George Applegate