date stamp for specific text change

gaztr1x

New Member
Joined
Nov 11, 2014
Messages
8
Hi, I have the macro below to put a date stamp in a cell ("U") when the text in another cell ("I") is changed. This works fine. However the original cell "I" automatically populates with "open" when a new row is created within the spreadsheet and A date stamp is created at this point. Therefore I would actually like it to only date stamp if the text specifically changes from "open" to "closed". I am not sure how to alter this macro to do that for me. Any help is appreciated.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim U As Range, AC As Range, t As Range
Set U = Range("U:U")
Set AC = Range("I:I")
Set t = Target
If Intersect(t, AC) Is Nothing Then Exit Sub
Application.EnableEvents = False
Range("U" & t.Row).Value = Now
Application.EnableEvents = True
End Sub

<tbody>
</tbody>
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim U As Range, AC As Range, t As Range

Set U = Range("U:U")
Set AC = Range("I:I")
Set t = Target

If Intersect(t, AC) Is Nothing Then Exit Sub
     Application.EnableEvents = False
     IF Range("A" & t.row).Value = "Cancel" Then
          Range("U" & t.Row).Value = Now
     End If
     Application.EnableEvents = True
End Sub
 
Upvote 0
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim U As Range, AC As Range, t As Range

Set U = Range("U:U")
Set AC = Range("I:I")
Set t = Target

If Intersect(t, AC) Is Nothing Then Exit Sub
     Application.EnableEvents = False
     IF Range("A" & t.row).Value = "Cancel" Then
          Range("U" & t.Row).Value = Now
     End If
     Application.EnableEvents = True
End Sub

Excellent. Thanks Redwolfx. Works a treat.
 
Upvote 0

Forum statistics

Threads
1,215,963
Messages
6,127,960
Members
449,412
Latest member
montand

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