Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Static Time/Date Stamp

How can I set up a Static Time/Date stamp to be posted in a cell
whenever another specific cell has any information in it or is this
possible? I never want the time or date to change.

Cell "A1" is empty until I enter info into it. Probably text, not a
number.
Cell "A2" is the date/time stamp cell. It will show a static date as
soon as info is
entered into cell "A1".

Thanks.

Keith

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Static Time/Date Stamp

Hi Keith,

How can I set up a Static Time/Date stamp to be posted in a cell
whenever another specific cell has any information in it or is this
possible? I never want the time or date to change.

Cell "A1" is empty until I enter info into it. Probably text, not a
number.
Cell "A2" is the date/time stamp cell. It will show a static date as
soon as info is entered into cell "A1".


You could use a UDF (user-defined function):

Public Function DATESTAMP(WatchedCell As Range) As Variant
If Len(WatchedCell.Value) Then
DATESTAMP = Now()
Else
DATESTAMP = ""
End If
End Function

In cell A2, you would enter:

=DATESTAMP(A1)

Although this is simple, it will change the datestamp any time the value in
the watched cell is changed. This may not be what you want. If you don't
want this, you'd probably want to use the Worksheet_Change event to watch
for the first change:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
If Len(Range("A2").Value) = 0 Then
Range("A2").Value = Now()
End If
End If
End Sub

This one goes "behind" the worksheet. To do this, you can right-click the
worksheet tab and select "View Code". Just paste the code above into the
resulting codepane, and it should work.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Static Time/Date Stamp

Jake,

Worked like a champ. Many thanks. I am not an expert at visual basic.
More like a beginner.

Keith

Jake Marx wrote:
Hi Keith,

How can I set up a Static Time/Date stamp to be posted in a cell
whenever another specific cell has any information in it or is this
possible? I never want the time or date to change.

Cell "A1" is empty until I enter info into it. Probably text, not a
number.
Cell "A2" is the date/time stamp cell. It will show a static date as
soon as info is entered into cell "A1".


You could use a UDF (user-defined function):

Public Function DATESTAMP(WatchedCell As Range) As Variant
If Len(WatchedCell.Value) Then
DATESTAMP = Now()
Else
DATESTAMP = ""
End If
End Function

In cell A2, you would enter:

=DATESTAMP(A1)

Although this is simple, it will change the datestamp any time the value in
the watched cell is changed. This may not be what you want. If you don't
want this, you'd probably want to use the Worksheet_Change event to watch
for the first change:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
If Len(Range("A2").Value) = 0 Then
Range("A2").Value = Now()
End If
End If
End Sub

This one goes "behind" the worksheet. To do this, you can right-click the
worksheet tab and select "View Code". Just paste the code above into the
resulting codepane, and it should work.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]


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
Date-Time Stamp [email protected] Excel Discussion (Misc queries) 1 September 27th 06 02:37 PM
How do i automate a static time stamp? Gavin Taylor Excel Discussion (Misc queries) 1 December 31st 05 02:08 PM
Date/time Stamp? Bowes813[_3_] Excel Programming 7 June 3rd 05 08:10 AM
Date time stamp Frank Kabel Excel Programming 3 March 1st 04 08:56 PM
Date time stamp Chip Pearson Excel Programming 0 March 1st 04 04:14 PM


All times are GMT +1. The time now is 09:25 AM.

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"