Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Display Current Date & Time in a cell: Everytime I open the workbo

Hi All,

Is there a way I can display Current Date & Time in a cell which updates
everytime I open the workbook?

Thanks in Advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Display Current Date & Time in a cell: Everytime I open the workbo

hi
in any cell you wish, enter........
=now()

the cell will update each time the workbook is opened or the sheet is
calculated.
formula is volital meaning it don't stay the same for long.
if you just want the date without time..
=today()

regards
FSt1


regards
FSt1




"sam" wrote:

Hi All,

Is there a way I can display Current Date & Time in a cell which updates
everytime I open the workbook?

Thanks in Advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Display Current Date & Time in a cell: Everytime I open the workbo

The following Event macro will put the current date/time in cell A1 of Sheet1:

Private Sub Workbook_Open()
Sheets("Sheet1").Range("A1").Value = Now
End Sub

Because it is workbook code, it is very easy to install and use:

1. right-click the tiny Excel icon just to the left of File on the Menu Bar
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (workbook code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200902


"sam" wrote:

Hi All,

Is there a way I can display Current Date & Time in a cell which updates
everytime I open the workbook?

Thanks in Advance

  #4   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Display Current Date & Time in a cell: Everytime I open the wo

Thanks gary, The issue I am having now is: I have a macro that saves the file
and names it with data in Cell A1 which contains the current date and time.
The macro is now giving me an error as I guess there is a ":" in Cell A1. I
am guessing this.

Thanks in advance

"Gary''s Student" wrote:

The following Event macro will put the current date/time in cell A1 of Sheet1:

Private Sub Workbook_Open()
Sheets("Sheet1").Range("A1").Value = Now
End Sub

Because it is workbook code, it is very easy to install and use:

1. right-click the tiny Excel icon just to the left of File on the Menu Bar
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (workbook code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200902


"sam" wrote:

Hi All,

Is there a way I can display Current Date & Time in a cell which updates
everytime I open the workbook?

Thanks in Advance

  #5   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Display Current Date & Time in a cell: Everytime I open the wo

Here is my code to save the file:

Private Sub ExportSave_Click()
Dim FName As String

Application.DisplayAlerts = False

FName = "C:\My Documents\" _
& "Book" & Range("A1").Value "-" & ".xls"

Sheets("Sheet1").Copy
ActiveWorkbook.SaveAs Filename:=FName
ActiveWorkbook.Close

End Sub

Now A1 cell contains the Date and Time stamp. It displays error when I run
this
macro..

Error--- Make sure the specified folder exists.
Make sure the folder that contains the file is not read-only
Make sure the file name does not containg any of the following
characters:
< ? [ ] : | *
Make sure the file/path name doesnt contain more than 218

Thanks in advance

"Gary''s Student" wrote:

The following Event macro will put the current date/time in cell A1 of Sheet1:

Private Sub Workbook_Open()
Sheets("Sheet1").Range("A1").Value = Now
End Sub

Because it is workbook code, it is very easy to install and use:

1. right-click the tiny Excel icon just to the left of File on the Menu Bar
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (workbook code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200902


"sam" wrote:

Hi All,

Is there a way I can display Current Date & Time in a cell which updates
everytime I open the workbook?

Thanks in Advance



  #6   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Display Current Date & Time in a cell: Everytime I open the wo

Hey Gary, I forgot to mention one thing.. I am going to save the file with
date and time stamp. But I dont want the value to update with current date
and time when I open any previous saved file. Sorry for the confusion before

Hope I made it clear

THanks in advance

"Gary''s Student" wrote:

The following Event macro will put the current date/time in cell A1 of Sheet1:

Private Sub Workbook_Open()
Sheets("Sheet1").Range("A1").Value = Now
End Sub

Because it is workbook code, it is very easy to install and use:

1. right-click the tiny Excel icon just to the left of File on the Menu Bar
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (workbook code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200902


"sam" wrote:

Hi All,

Is there a way I can display Current Date & Time in a cell which updates
everytime I open the workbook?

Thanks in Advance

  #7   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Display Current Date & Time in a cell: Everytime I open the wo

Hey FSt1, I forgot to mention one thing.. I am going to save the file with
date and time stamp(from that cell). But I dont want the date and time value
to update with current date and time when I open any previous saved file.
Sorry for the confusion before

Hope I made it clear

THanks in advance

"FSt1" wrote:

hi
in any cell you wish, enter........
=now()

the cell will update each time the workbook is opened or the sheet is
calculated.
formula is volital meaning it don't stay the same for long.
if you just want the date without time..
=today()

regards
FSt1


regards
FSt1




"sam" wrote:

Hi All,

Is there a way I can display Current Date & Time in a cell which updates
everytime I open the workbook?

Thanks in Advance

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default Display Current Date & Time in a cell: Everytime I open the wo

Adapting Gary's code:

Private Sub Workbook_Open()
If Sheets("Sheet1").Range("A1").Value = "" Then
Sheets("Sheet1").Range("A1").Value = now()
End Sub

You are correct on your other post- if you are trying to save this as your
workbook name, you will probably need to eliminate any special characters
(I'd think the slashes in the date will also be problematic).

Consider the following option; although it isn't as easily readable (what
time is 1609 again?) this might work for you, and still allows you to easily
sort your directories. My PC defaults the hours parameter to military (24
hour) time, so I'd suggest testing it to make sure that it performs as
expected- so you don't have a 4pm file show up as 04xx instead of 16xx and
throw off the order

Private Sub Workbook_Open()

TimeText= Year(Now()) & Format(Month(Now), "00") & Format(Day(Now), "00") &
" " & Format(Hour(Now()), "00") & Format(Minute(Now()), "00")

If Sheets("Sheet1").Range("A1").Value = "" Then
Sheets("Sheet1").Range("A1").Value = TimeText

End Sub



"sam" wrote:

Hey Gary, I forgot to mention one thing.. I am going to save the file with
date and time stamp. But I dont want the value to update with current date
and time when I open any previous saved file. Sorry for the confusion before

Hope I made it clear

THanks in advance

"Gary''s Student" wrote:

The following Event macro will put the current date/time in cell A1 of Sheet1:

Private Sub Workbook_Open()
Sheets("Sheet1").Range("A1").Value = Now
End Sub

Because it is workbook code, it is very easy to install and use:

1. right-click the tiny Excel icon just to the left of File on the Menu Bar
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (workbook code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200902


"sam" wrote:

Hi All,

Is there a way I can display Current Date & Time in a cell which updates
everytime I open the workbook?

Thanks in Advance

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Display Current Date & Time in a cell: Everytime I open the wo

no you're not. the following are forbidden by excel as file nameing
convictions.......
: / \ * [ ]
make a note.
the slashes in the date are forbidden by dos becasue dos would interpet them
as switches and do weird thing or throw up errors.
instead of using the "date in a cell" method, use something like this in
your nameing code....
timestamp = Format(Month(Now), "00") & Format(Day(Now), "00") & _
Format(Year(Now), "0000") & "_" & Format(Hour(Now), "00") _
& ":" & Format(Minute(Now), "00")

or similar.

nice time to bring up..."oh! i forgot to mention......."

FSt1
geez

"sam" wrote:

Hey FSt1, I forgot to mention one thing.. I am going to save the file with
date and time stamp(from that cell). But I dont want the date and time value
to update with current date and time when I open any previous saved file.
Sorry for the confusion before

Hope I made it clear

THanks in advance

"FSt1" wrote:

hi
in any cell you wish, enter........
=now()

the cell will update each time the workbook is opened or the sheet is
calculated.
formula is volital meaning it don't stay the same for long.
if you just want the date without time..
=today()

regards
FSt1


regards
FSt1




"sam" wrote:

Hi All,

Is there a way I can display Current Date & Time in a cell which updates
everytime I open the workbook?

Thanks in Advance

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display Current Date & Time in a cell: Everytime I open the workbo sam Excel Worksheet Functions 4 September 3rd 09 11:30 PM
Why are my Add-In formulas recalculating everytime I open a workbo J. Caplan[_2_] Excel Programming 7 July 18th 08 03:47 PM
Keep original header date everytime I open, it always changes. Momma Bear Excel Discussion (Misc queries) 1 June 6th 07 03:45 PM
How do I code a cell to display the current date on double-click? George[_27_] Excel Programming 6 December 10th 06 09:26 AM
how do I display username, current time & date on the status bar Gary Tan Excel Programming 4 July 25th 06 06:29 AM


All times are GMT +1. The time now is 06:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"