Time stamp for a specific cell value

xerox_04

New Member
Joined
Feb 10, 2014
Messages
3
Hello guys,

I have something like 300 rows. I want to get a time stamp at column A when column B is equal to "Non" (by default it is equal to "Oui"). To do that, I have to change the value of column C which has a conditional formula. I can change the value at any row, and I want the time stamp in the row which I have selected. I've been struggling to do that with no success. Please help me with the code, I don't know how to do that. This is what I have right now:

Private Sub Worksheet_Change(ByVal Target As Range)
If Cells(Target.Row, "B") = Non Then
Cells(Target.Row, "A") = Date
End If
End Sub

By the way, when I paste some VBA code in excel table file, if I press ctrl+z (undo) it does not undo...why does it happen?

Thank you very much in advance!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I've been struggling to do that with no success.
Hi and welcome to the board.
Try adding a set of double quotes around the value Non. (ie.)
If Cells(Target.Row, "B") = "Non" Then

Not sure about the undo part of your question. For me, it does in fact undo the paste using Ctrl+Z.
 
Upvote 0
Thank you HalfAce!! =) That worked for me, but actually it slows down my computer a lot...why is this happening?
 
Upvote 0
I can't really see why that (in itself) would slow your machine down, except for the fact that as written, the code is being executed with each & every change on your worksheet. See if it helps by adding this handful of lines of code.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("C:C")) Is Nothing Then Exit Sub
On Error GoTo Quit
With Application
  .ScreenUpdating = False
  .EnableEvents = False
  If Cells(Target.Row, "B") = "Non" Then
    Cells(Target.Row, "A") = Date
  End If
Quit:
  .ScreenUpdating = True
  .EnableEvents = True
End With
End Sub

Does that help speed things up a bit?
 
Upvote 0

Forum statistics

Threads
1,223,713
Messages
6,174,039
Members
452,542
Latest member
Bricklin

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