Why does this not work? I\'m trying to get excel to check for any changes in column B and D if column B has changed then do some actions and so on.
Private Sub W
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lc As Long
Dim TEMPVAL As String
Dim ws1, ws2 As Worksheet
Dim myDay As String
Set ws1 = ThisWorkbook.Sheets("Lists")
myDay = Format(myDate, "ffffdd")
'If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
If Target = "" Then Exit Sub
If Target.Column = 2 Then
If Target = "" Then Exit Sub
MsgBox "Row: " & Target.Row & "Column: " & lc
With Application
'.EnableEvents = False
.ScreenUpdating = False
Cells(Target.Row, lc + 1) = Target.Row - 1
Cells(Target.Row, lc + 3) = Format(Date, "dd-MMM-yyyy")
Cells(Target.Row, lc + 4) = Application.WorksheetFunction.VLookup(Target, ws1.Range("A2:C29"), 3, False)
Cells(Target.Row, lc + 5) = 7.6
Cells(Target.Row, lc + 7) = Application.WorksheetFunction.VLookup(Target, ws1.Range("A2:C29"), 2, False)
Cells(Target.Row, lc + 8) = myDay
Cells(Target.Row, lc + 10) = WORKCODE(Target.Row, lc + 4)
.EnableEvents = True
.ScreenUpdating = True
End With
ElseIf Target.Column = 4 Then
'If Intersect(Target, Range("D2:D5002")) Is Nothing Then Exit Sub
'If Target = "" Then Exit Sub
MsgBox "Row: " & Target.Row & "Column: " & lc
With Application
'.EnableEvents = False
.ScreenUpdating = False
Cells(Target.Row, lc + 10) = WORKCODE(Target.Row, lc + 4)
'.EnableEvents = True
.ScreenUpdating = True
End With
End If
End Sub