Hello, need help with combining these 2 worksheet change events. Tried combining both under 1 worksheet change, didn't work. Anyways, here's the code. Please help, what's wrong?
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim MyRange As Range
Dim c As Range
Dim MyRange2 As Range
Dim c2 As Range
Set MyRange = Intersect(Target, Range("K5:K284"))
Set MyRange2 = Intersect(Target, Range("C5:K284"))
If Not MyRange Is Nothing Then
Application.EnableEvents = False
For Each c In MyRange
If IsEmpty(c.Value) Then
c.Offset(0, 1).ClearContents
Else
With c.Offset(0, 1)
.NumberFormat = "dd mmmm yyyy"
.Value = Date
End With
End If
Next c
Application.EnableEvents = True
End If
If Not MyRange2 Is Nothing Then
Application.EnableEvents = False
For Each c2 In MyRange
If IsEmpty(c2.Value) Then
c.Offset(0, -1).ClearContents
Else
With c.Offset(0, -1)
.NumberFormat = "dd mmmm yyyy"
.Value = Date
End With
End If
Next c
Application.EnableEvents = True
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim MyRange As Range
Dim c As Range
Dim MyRange2 As Range
Dim c2 As Range
Set MyRange = Intersect(Target, Range("K5:K284"))
Set MyRange2 = Intersect(Target, Range("C5:K284"))
If Not MyRange Is Nothing Then
Application.EnableEvents = False
For Each c In MyRange
If IsEmpty(c.Value) Then
c.Offset(0, 1).ClearContents
Else
With c.Offset(0, 1)
.NumberFormat = "dd mmmm yyyy"
.Value = Date
End With
End If
Next c
Application.EnableEvents = True
End If
If Not MyRange2 Is Nothing Then
Application.EnableEvents = False
For Each c2 In MyRange
If IsEmpty(c2.Value) Then
c.Offset(0, -1).ClearContents
Else
With c.Offset(0, -1)
.NumberFormat = "dd mmmm yyyy"
.Value = Date
End With
End If
Next c
Application.EnableEvents = True
End If
End Sub