PC Review


Reply
Thread Tools Rate Thread

date and time stamp on command

 
 
J.W. Aldridge
Guest
Posts: n/a
 
      16th Nov 2006
Hi.

I have the formula in which if I update a cell in a row, column A will
time stamp the change.

Private Sub Worksheet_Change(ByVal Target As Range)
Range("A" & Target.Row) = Now()
End Sub


However, I would like to have a time stamp in column A, whenever the
same row (column B) is updated with a "Y". I am keeping a daily log and
want to be able to control the date and time stamped by placing a Y in
column B. I want to know what time a Y was placed on the row.

In short terms, Y = date/time stamp, no Y, no date/time stamp.

Example below:

A B C
11/16/2006 10:59 Y Sheila
poked me in the eye.

I poked her back!
11/16/2006 11:00 Y She poked
me again!


Any suggestions?

 
Reply With Quote
 
 
 
 
Ardus Petus
Guest
Posts: n/a
 
      16th Nov 2006
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rChanged As Range
Dim rCell As Range
Set rChanged = Intersect(Target, Columns("B"))
If Not rChanged Is Nothing Then
For Each rCell In rChanged.Cells
If LCase(rCell.Value) = "y" Then
Cells(rCell.Row, "A") = Now()
End If
Next rCell
End If
End Sub


Cheers,
--
AP

"J.W. Aldridge" <(E-Mail Removed)> a écrit dans le message de
news: (E-Mail Removed)...
> Hi.
>
> I have the formula in which if I update a cell in a row, column A will
> time stamp the change.
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Range("A" & Target.Row) = Now()
> End Sub
>
>
> However, I would like to have a time stamp in column A, whenever the
> same row (column B) is updated with a "Y". I am keeping a daily log and
> want to be able to control the date and time stamped by placing a Y in
> column B. I want to know what time a Y was placed on the row.
>
> In short terms, Y = date/time stamp, no Y, no date/time stamp.
>
> Example below:
>
> A B C
> 11/16/2006 10:59 Y Sheila
> poked me in the eye.
>
> I poked her back!
> 11/16/2006 11:00 Y She poked
> me again!
>
>
> Any suggestions?
>



 
Reply With Quote
 
J.W. Aldridge
Guest
Posts: n/a
 
      16th Nov 2006
When I update a row, all the times and dates change.
Any way to keep the previous ones (date & times) from changing?

 
Reply With Quote
 
Ardus Petus
Guest
Posts: n/a
 
      16th Nov 2006
My code updates only the rows with "Y" or "y" in column B.

It does not change other rows

--
AP

"J.W. Aldridge" <(E-Mail Removed)> a écrit dans le message de
news: (E-Mail Removed)...
> When I update a row, all the times and dates change.
> Any way to keep the previous ones (date & times) from changing?
>



 
Reply With Quote
 
J.W. Aldridge
Guest
Posts: n/a
 
      16th Nov 2006

Ardus Petus wrote:
> My code updates only the rows with "Y" or "y" in column B.
>
> It does not change other rows
>


Right. And I do not want the other rows to change either however...

Currently,
If row 1 has a time stamp of 11/16/06 2:32 PM when I put the "y" in
column B.

It changes to the current time 11/16/06 2:33 PM when I update row 2
column B with the "y".

I need this to be like a timed diary of each separate event with a "Y"
Any way to record the first time a y is placed in (column B) row and
have that time not to change if I should add a Y when I go to the next
row?

thanx

 
Reply With Quote
 
Ardus Petus
Guest
Posts: n/a
 
      16th Nov 2006
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rChanged As Range
Dim rCell As Range
Set rChanged = Intersect(Target, Columns("B"))
If Not rChanged Is Nothing Then
For Each rCell In rChanged.Cells
If LCase(rCell.Value) = "y" Then
With Cells(rCell.Row, "A")
If IsEmpty(.Value) Then .Value = Now()
End With
End If
Next rCell
End If
End Sub

HTH,
--
AP

"J.W. Aldridge" <(E-Mail Removed)> a écrit dans le message de
news: (E-Mail Removed)...
>
> Ardus Petus wrote:
>> My code updates only the rows with "Y" or "y" in column B.
>>
>> It does not change other rows
>>

>
> Right. And I do not want the other rows to change either however...
>
> Currently,
> If row 1 has a time stamp of 11/16/06 2:32 PM when I put the "y" in
> column B.
>
> It changes to the current time 11/16/06 2:33 PM when I update row 2
> column B with the "y".
>
> I need this to be like a timed diary of each separate event with a "Y"
> Any way to record the first time a y is placed in (column B) row and
> have that time not to change if I should add a Y when I go to the next
> row?
>
> thanx
>



 
Reply With Quote
 
J.W. Aldridge
Guest
Posts: n/a
 
      16th Nov 2006
.......worked like a charm!

THANX!

 
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
Command Button - Date stamp learning_codes@hotmail.com Microsoft Access Forms 1 9th Nov 2007 04:32 PM
date stamp + command button =?Utf-8?B?Sks=?= Microsoft Access VBA Modules 0 27th Apr 2007 05:52 PM
Command Button Date/Time Stamp =?Utf-8?B?c2t5?= Microsoft Excel Programming 4 11th Jan 2006 12:04 AM
DOS copy command with date stamp greg w Windows XP General 3 24th Nov 2004 06:38 PM
Command prompt time stamp Catello Windows XP General 0 4th Feb 2004 12:07 PM


Features
 

Advertising
 

Newsgroups
 


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