I am trying to have the date and time entered into cells in columns "A", "B" and "C" with a "Y" placed in columns "C" or "E". Date only in column "A" and the time in columns "B" and "C". I have worked on this all day and cannot get it to work. I get no error messages but absolutly nothing happens. Below is my VBA code. Thanks in advance for any help I may receive.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet
Set ws = ActiveWorkbook.Worksheets("Sheet1")
Dim lastcell
lastcell = ActiveCell.Address
Set ws = ActiveWorkbook.Worksheets("Sheet1")
With ws
.Unprotect
Application.EnableEvents = False
Application.ScreenUpdating = False
If Not Intersect(Target, Range("C6:C36,E6:E36")) Is Nothing Then
If .Cells(Target.Row, "C") = "N" Then
.Cells(Target.Row, "A") = ""
.Cells(Target.Row, "B") = ""
End If
Else
If .Cells(Target.Row, "C") = "Y" Then
If .Cells(Target.Row, "A") = "" Then
.Cells(Target.Row, "A") = Now()
.Cells(Target.Row, "B") = Now()
Else
.Cells(Target.Row, "A") = ""
.Cells(Target.Row, "B") = ""
End If
If .Cells(Target.Row, "E") = "N" Then
.Cells(Target.Row, "D") = ""
End If
Else
If .Cells(Target.Row, "E") = "Y" Then
If .Cells(Target.Row, "D") = "" Then
.Cells(Target.Row, "D") = Now()
End If
Else
.Cells(Target.Row, "D") = ""
End If
End If
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End With
ws.Range(lastcell).Select
End Sub
Last edited by a moderator: