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 :).
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
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
 

Dicko

New Member
Joined
Jan 27, 2010
Messages
21
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!
 

Watch MrExcel Video

Forum statistics

Threads
1,109,366
Messages
5,528,269
Members
409,813
Latest member
robyrux

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top