Conditional time stamping

Mark Mackay

New Member
Joined
Nov 18, 2009
Messages
3
Using "control shift colon ( : )" a time stamp can be put in a cell. I want to add a time stamp every time a drop-down menu option is chosen. Can anyone please help me with a method for doing this? Some additional context: I want to have two columns - call col A the drop-down menu column and col B the time stamp col. I will select from col A at different times throughout a session. Indeed - it is possible that I will have several sets of col A and col B on the same worksheet.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi and welcome to the Board!!
Code:
Private Sub WorkSheet_Change(ByVal Target as Range)
If Target.Count > 1 Then Exit Sub 'Work only if one cell is changed
If Target.Column <>1 Then Exit Sub 'Work only if Col "A" is changed
Cells(Target.Row,2) = Time 'Put time in Col "B"
End Sub
This goes in the WorkSheet module. Right Click the sheet tab and choose "View Code"
That will do what you asked!!
That said, what do you really need to do? There might be something better
lenze
 
Upvote 0
Hi Lenze

many thanks for your quick response. I'm using excel to capture observations. So column A is my drop down list of the observation and column b is the time stamp of when I record it. You might think that it's trivial to ask someone to use control shift colon, but this would represent an extra thing to think about when we want their focus on the observing. So recording needs to be as easy as possible. An ideas to do this in a different way would be welcomed.

Mark
 
Upvote 0
Just try the code I posted then. It will do what you require. When you change a cell in Col "A, the time will be entered in Col "B" And it's not trivial to automate repetitive tasks such as this!!
lenze
 
Upvote 0
How could you do this with multiple columns?

In other words a selection from a drop down in column "a" puts a time stamp in column "b", and/or a selection in column "d" puts a time stamp in column "e" ?

my example is i'm tracking when a request is made in column "a" and when an answer is given in column "d" (tracking response times)...

Thanks for your time.
 
Upvote 0
Hi ProZak and welcome to the Board!!
Rich (BB code):
Private Sub WorkSheet_Change(ByVal Target as Range)
If Target.Count > 1 Then Exit Sub 'Work only if one cell is changed
If Target.Column <>1 And Target.Column <> 4 Then Exit Sub 'Work only if Col "A" or "D" is changed
Cells(Target.Row,Target.Column +1) = Time 'Put time in Col "B" or "D"
End Sub

If you have more than 2 or 3 columns, there may be a better approach. If you need more help, post your specifics.
lenze
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,748
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top