IF text is specific THEN result is date/time

Dicko

New Member
Joined
Jan 27, 2010
Messages
21
I have the following code which gives a result of the current date/time in column "C" if any text/number is entered in column "G".

col = Left(Target.Address, 2)
If col = "$G" Then Target.Offset(0, -4) = Now()

I need to edit this so column "C" only displays the time/date if text in column "G" is specifically "YES".
If any other text/number is entered in column "G" then column "C" is to remain empty.

I would appreciate any suggestions or advice :).
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 7 And Target.Value = "YES" Then
    Application.EnableEvents = False
    Target.Offset(, -4).Value = Now
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 7 And Target.Value = "YES" Then
    Application.EnableEvents = False
    Target.Offset(, -4).Value = Now
    Application.EnableEvents = True
End If
End Sub

Many thanks for your assistance...just tested and exactly what I required...appreciate your fast post :):):). Vba rocks!
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,269
Members
449,075
Latest member
staticfluids

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