PC Review


Reply
Thread Tools Rate Thread

Automatic Time and Date

 
 
Larry
Guest
Posts: n/a
 
      15th Aug 2008
Hi, I have a situation similar to D. West where I'd like for the current
time and date to be entered in col. A whenever a new row is populated with
values. I tried the setting col. A to: =IF(COUNTA(B3:IV3)<>0,NOW(),"") like
Gary Brown suggested for D.West. That sort of worked, but I'd like for that
value to remain, not be subject to recalculation whenever something new is
added to that or other rows. Any way to specify that value to remain
unchanged once it's calculated the first time? Thanks.
Larry


 
Reply With Quote
 
 
 
 
Jarek Kujawa
Guest
Posts: n/a
 
      15th Aug 2008
you might try to use Worksheet_Change event (go to sheet tab, right-
click on it, click Show code, instead of "(General)" select
"Worksheet" and then "Change" in the rightmost window)

Private Sub Worksheet_Change(ByVal Target As Range)
Cells(Selection.Row - 1, 1) = Time
End Sub

provided entering data moves you 1 row down
however this will cause time to be entered to cells in 1st column also
on editing any cell

HIH
 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      15th Aug 2008
Private Sub WorkSheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B:B")) Is Nothing Then
With Target
If .Value <> "" Then
.Offset(0, -1).Value = Format(Now, "dd mmm yyyy hh:mm:ss")
End If
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

Will add a timestamp to cell in column A when a change is made in
corresponding cell in row of column B

The timestamp does not update unless column A is edited.

This is sheet event code. Right-click on the sheet tab and "Viedw Code"

Copy/paste into that sheet module.

Alt + q to return to the Excel window.


Gord Dibben MS Excel MVP


On Fri, 15 Aug 2008 15:47:59 -0400, "Larry"
<(E-Mail Removed)> wrote:

>Hi, I have a situation similar to D. West where I'd like for the current
>time and date to be entered in col. A whenever a new row is populated with
>values. I tried the setting col. A to: =IF(COUNTA(B3:IV3)<>0,NOW(),"") like
>Gary Brown suggested for D.West. That sort of worked, but I'd like for that
>value to remain, not be subject to recalculation whenever something new is
>added to that or other rows. Any way to specify that value to remain
>unchanged once it's calculated the first time? Thanks.
>Larry
>


 
Reply With Quote
 
Larry
Guest
Posts: n/a
 
      15th Aug 2008
Hi Jarek. I couldn't get it to work. I may have the Cell callout messed up.
Can you show me an example of what to put in for "Cells(Selection.Row - 1,
1) = Time". Thanks.
Larry

"Jarek Kujawa" <(E-Mail Removed)> wrote in message
news:c11bb8e8-16af-4e10-8065-(E-Mail Removed)...
> you might try to use Worksheet_Change event (go to sheet tab, right-
> click on it, click Show code, instead of "(General)" select
> "Worksheet" and then "Change" in the rightmost window)
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Cells(Selection.Row - 1, 1) = Time
> End Sub
>
> provided entering data moves you 1 row down
> however this will cause time to be entered to cells in 1st column also
> on editing any cell
>
> HIH



 
Reply With Quote
 
Larry
Guest
Posts: n/a
 
      15th Aug 2008
Gord, thanks. Your suggestion seems to work great. Now, I don't really want
the date stamp in column A. How do I change the date stamp to, say, column
E?
Thanks.
Larry

"Gord Dibben" <gorddibbATshawDOTca> wrote in message
news:(E-Mail Removed)...
> Private Sub WorkSheet_Change(ByVal Target As Range)
> On Error GoTo ws_exit:
> Application.EnableEvents = False
> If Not Intersect(Target, Me.Range("B:B")) Is Nothing Then
> With Target
> If .Value <> "" Then
> .Offset(0, -1).Value = Format(Now, "dd mmm yyyy hh:mm:ss")
> End If
> End With
> End If
> ws_exit:
> Application.EnableEvents = True
> End Sub
>
> Will add a timestamp to cell in column A when a change is made in
> corresponding cell in row of column B
>
> The timestamp does not update unless column A is edited.
>
> This is sheet event code. Right-click on the sheet tab and "Viedw Code"
>
> Copy/paste into that sheet module.
>
> Alt + q to return to the Excel window.
>
>
> Gord Dibben MS Excel MVP
>
>
> On Fri, 15 Aug 2008 15:47:59 -0400, "Larry"
> <(E-Mail Removed)> wrote:
>
>>Hi, I have a situation similar to D. West where I'd like for the current
>>time and date to be entered in col. A whenever a new row is populated with
>>values. I tried the setting col. A to: =IF(COUNTA(B3:IV3)<>0,NOW(),"")
>>like
>>Gary Brown suggested for D.West. That sort of worked, but I'd like for
>>that
>>value to remain, not be subject to recalculation whenever something new is
>>added to that or other rows. Any way to specify that value to remain
>>unchanged once it's calculated the first time? Thanks.
>>Larry
>>

>


 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      16th Aug 2008
Column E Offset from column B would be

..Offset(0, 3) instead of .Offset(0, -1)

Offset(Row, Column) is the syntax.


Gord

On Fri, 15 Aug 2008 18:28:45 -0400, "Larry"
<(E-Mail Removed)> wrote:

>Gord, thanks. Your suggestion seems to work great. Now, I don't really want
>the date stamp in column A. How do I change the date stamp to, say, column
>E?
>Thanks.
>Larry
>
>"Gord Dibben" <gorddibbATshawDOTca> wrote in message
>news:(E-Mail Removed)...
>> Private Sub WorkSheet_Change(ByVal Target As Range)
>> On Error GoTo ws_exit:
>> Application.EnableEvents = False
>> If Not Intersect(Target, Me.Range("B:B")) Is Nothing Then
>> With Target
>> If .Value <> "" Then
>> .Offset(0, -1).Value = Format(Now, "dd mmm yyyy hh:mm:ss")
>> End If
>> End With
>> End If
>> ws_exit:
>> Application.EnableEvents = True
>> End Sub
>>
>> Will add a timestamp to cell in column A when a change is made in
>> corresponding cell in row of column B
>>
>> The timestamp does not update unless column A is edited.
>>
>> This is sheet event code. Right-click on the sheet tab and "Viedw Code"
>>
>> Copy/paste into that sheet module.
>>
>> Alt + q to return to the Excel window.
>>
>>
>> Gord Dibben MS Excel MVP
>>
>>
>> On Fri, 15 Aug 2008 15:47:59 -0400, "Larry"
>> <(E-Mail Removed)> wrote:
>>
>>>Hi, I have a situation similar to D. West where I'd like for the current
>>>time and date to be entered in col. A whenever a new row is populated with
>>>values. I tried the setting col. A to: =IF(COUNTA(B3:IV3)<>0,NOW(),"")
>>>like
>>>Gary Brown suggested for D.West. That sort of worked, but I'd like for
>>>that
>>>value to remain, not be subject to recalculation whenever something new is
>>>added to that or other rows. Any way to specify that value to remain
>>>unchanged once it's calculated the first time? Thanks.
>>>Larry
>>>

>>


 
Reply With Quote
 
Jarek Kujawa
Guest
Posts: n/a
 
      16th Aug 2008
....Gord's solution is very good...
 
Reply With Quote
 
D. West
Guest
Posts: n/a
 
      19th Aug 2008
This worked!!! You guys are lifesavers! Thanks so much. I do have one other
question. Is there any way to change it to regular time instead of military
time?

"Gord Dibben" wrote:

> Column E Offset from column B would be
>
> ..Offset(0, 3) instead of .Offset(0, -1)
>
> Offset(Row, Column) is the syntax.
>
>
> Gord
>
> On Fri, 15 Aug 2008 18:28:45 -0400, "Larry"
> <(E-Mail Removed)> wrote:
>
> >Gord, thanks. Your suggestion seems to work great. Now, I don't really want
> >the date stamp in column A. How do I change the date stamp to, say, column
> >E?
> >Thanks.
> >Larry
> >
> >"Gord Dibben" <gorddibbATshawDOTca> wrote in message
> >news:(E-Mail Removed)...
> >> Private Sub WorkSheet_Change(ByVal Target As Range)
> >> On Error GoTo ws_exit:
> >> Application.EnableEvents = False
> >> If Not Intersect(Target, Me.Range("B:B")) Is Nothing Then
> >> With Target
> >> If .Value <> "" Then
> >> .Offset(0, -1).Value = Format(Now, "dd mmm yyyy hh:mm:ss")
> >> End If
> >> End With
> >> End If
> >> ws_exit:
> >> Application.EnableEvents = True
> >> End Sub
> >>
> >> Will add a timestamp to cell in column A when a change is made in
> >> corresponding cell in row of column B
> >>
> >> The timestamp does not update unless column A is edited.
> >>
> >> This is sheet event code. Right-click on the sheet tab and "Viedw Code"
> >>
> >> Copy/paste into that sheet module.
> >>
> >> Alt + q to return to the Excel window.
> >>
> >>
> >> Gord Dibben MS Excel MVP
> >>
> >>
> >> On Fri, 15 Aug 2008 15:47:59 -0400, "Larry"
> >> <(E-Mail Removed)> wrote:
> >>
> >>>Hi, I have a situation similar to D. West where I'd like for the current
> >>>time and date to be entered in col. A whenever a new row is populated with
> >>>values. I tried the setting col. A to: =IF(COUNTA(B3:IV3)<>0,NOW(),"")
> >>>like
> >>>Gary Brown suggested for D.West. That sort of worked, but I'd like for
> >>>that
> >>>value to remain, not be subject to recalculation whenever something new is
> >>>added to that or other rows. Any way to specify that value to remain
> >>>unchanged once it's calculated the first time? Thanks.
> >>>Larry
> >>>
> >>

>
>

 
Reply With Quote
 
Jarek Kujawa
Guest
Posts: n/a
 
      19th Aug 2008
re-format yr cells
HIH
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic Refresh Date and Time jaeson Microsoft Excel Programming 1 30th Dec 2009 08:41 PM
Automatic date or time in forms =?Utf-8?B?bWFyamFu?= Microsoft Excel Programming 5 15th Jun 2006 01:06 PM
date/time automatic update is off but date still updates. =?Utf-8?B?am9jYXNhbQ==?= Microsoft Word Document Management 2 11th Feb 2006 03:50 PM
automatic date and time while still running =?Utf-8?B?TmV0LW9yaW91cw==?= Microsoft Powerpoint 1 25th Jan 2006 02:23 PM
date, time automatic plus 2 days? Guurt Microsoft Powerpoint 0 17th May 2005 04:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:16 PM.