I have the following code , inserted within the Worksheet_Change event, and it works fine there.
However, if i make this exact code a stand alone sub routine, Private Sub Test(), and Call Test in the Worksheet_Change Sub, it gives me 'Run-time error 424: Object required, when the first IF Not Intersect.....line runs.
I don't understand why? Thanks
However, if i make this exact code a stand alone sub routine, Private Sub Test(), and Call Test in the Worksheet_Change Sub, it gives me 'Run-time error 424: Object required, when the first IF Not Intersect.....line runs.
I don't understand why? Thanks
VBA Code:
Application.EnableEvents = False
Application.ScreenUpdating = False
If Not Intersect(Target, Range("AF8:AF157")) Is Nothing Then
Range("E8:E37").Value = Range("AF8:AF37").Value
Range("I8:I37").Value = Range("AF38:AF67").Value
Range("L8:L37").Value = Range("AF68:AF97").Value
Range("O8:O37").Value = Range("AF98:AF127").Value
Range("R8:R37").Value = Range("AF128:AF157").Value
End If
If Not Intersect(Target, Range("E8:E37,I8:I37,L8:L37,O8:O37,R8:R37")) Is Nothing Then
Range("AF8:AF37").Value = Range("E8:E37").Value
Range("AF38:AF67").Value = Range("I8:I37").Value
Range("AF68:AF97").Value = Range("L8:L37").Value
Range("AF98:AF127").Value = Range("O8:O37").Value
Range("AF128:AF157").Value = Range("R8:R37").Value
End If
Application.EnableEvents = True
Application.ScreenUpdating = True