I', still really new to the coding aspect of excel and need some help.
I have created a tracking sheet, what i want is when someone enters their name via a drop down menu in column A that a date and time stamp would appear in column C. i want this code to repeat for when something is placed in Column 7 that a time stamp appears in column D. The code that is not working is below
Private Sub Worksheet_Change(ByVal Target As Range)
'Update 20140722
Dim WorkRngA As Range
Dim WorkRngB As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
Set WorkRngA = Intersect(Application.ActiveSheet.Range("A:A"), Target)
Set WorkRngB = Intersect(Application.ActiveSheet.Range("F:F"), Target)
xOffsetColumn = 2
Application.EnableEvents = False
If Not WorkRng Is Nothing Then
For Each Rng In WorkRngA
If Not VBA.IsEmpty(Rng.Value) Then
Rng.Offset(0, xOffsetColumn).Value = Date
Rng.Offset(0, xOffsetColumn).NumberFormat = "mm/dd/yyyy"
Else
Rng.Offset(0, xOffsetColumn).ClearContents
End If
Next
End If
'repeat for 2nd range
xOffsetColumn = -2
If Not WorkRngB Is Nothing Then
For Each Rng In WorkRngB
If Not VBA.IsEmpty(Rng.Value) Then
Rng.Offset(0, xOffsetColumn).Value = Date
Rng.Offset(0, xOffsetColumn).NumberFormat = "mm/dd/yyyy"
Else
Rng.Offset(0, xOffsetColumn).ClearContents
End If
Next
End If
Application.EnableEvents = True
End Sub
I have created a tracking sheet, what i want is when someone enters their name via a drop down menu in column A that a date and time stamp would appear in column C. i want this code to repeat for when something is placed in Column 7 that a time stamp appears in column D. The code that is not working is below
Private Sub Worksheet_Change(ByVal Target As Range)
'Update 20140722
Dim WorkRngA As Range
Dim WorkRngB As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
Set WorkRngA = Intersect(Application.ActiveSheet.Range("A:A"), Target)
Set WorkRngB = Intersect(Application.ActiveSheet.Range("F:F"), Target)
xOffsetColumn = 2
Application.EnableEvents = False
If Not WorkRng Is Nothing Then
For Each Rng In WorkRngA
If Not VBA.IsEmpty(Rng.Value) Then
Rng.Offset(0, xOffsetColumn).Value = Date
Rng.Offset(0, xOffsetColumn).NumberFormat = "mm/dd/yyyy"
Else
Rng.Offset(0, xOffsetColumn).ClearContents
End If
Next
End If
'repeat for 2nd range
xOffsetColumn = -2
If Not WorkRngB Is Nothing Then
For Each Rng In WorkRngB
If Not VBA.IsEmpty(Rng.Value) Then
Rng.Offset(0, xOffsetColumn).Value = Date
Rng.Offset(0, xOffsetColumn).NumberFormat = "mm/dd/yyyy"
Else
Rng.Offset(0, xOffsetColumn).ClearContents
End If
Next
End If
Application.EnableEvents = True
End Sub