Timestamp

rubinda

New Member
Joined
Jun 26, 2018
Messages
36
I am trying to enter a timestamp in column B when data is entered in column A. If column B changes, I’d like the timestamp to change. I have the following code, but it is not working (I am new to this…).

Sub Timestamp()
If Target.Column = 1 And Target.Offset(0, 1).Value = "" Then
Target.Offset(0, 1) = Format(Now(), "HH:MM:SS")
End If
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Enter a value in column A and exit the cell. The time stamp will be placed in column B. What do you mean by:
If column B changes, I’d like the timestamp to change.
 
Upvote 0
First you said if data in column A changes you want a time stamp in column B
But then you said if column B changes you want a time stamp in column B

So are you asking for this to happen automatically any time you change a value or enter a value in column A?
So if the value in A20 changes you want todays date in in B20 is that what you want?

But then you said if something changes in column B you want a time stamp in column B

So this would mean if I enter George in B20 then todays date will be entered in B20 overwriting what you just entered.
 
Upvote 0
I want the timestamp in column A if column B changes.

I would like this happen automatically if column B changes.

If the value in B20 changes, I would like A20 to update automatically.
 
Upvote 0
You said this in your first posting
I am trying to enter a timestamp in column B when data is entered in column A.
 
Upvote 0
Please help if you are able to...

I want the timestamp in column A if column B changes.

I would like this happen automatically if column B changes.

If the value in B20 changes, I would like A20 to update automatically.
 
Upvote 0
Try this:
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 7/3/18 10:35 AM EDT
If Not Intersect(Target, Range("B:B")) Is Nothing Then
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
Target.Offset(, -1).Value = Format(Now(), "HH:MM:SS")
End If
End Sub
 
Upvote 0
I get an "object required" error for If Target.Column = 1 And Target.Offset(0, 1).Value = "" Then
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
    If Target.Offset(0, -1) = "" Then
        Target.Offset(0, -1) = Format(Now(), "HH:MM:SS")
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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