Reputation: 11
Trying to make a code for a spreadsheet I'm working on, I do not have prior experience and found an example online. The first part of the code works fine, but when I try to bring in the second "if not" my code does not run. Any help would be greatly appreciated.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range"Adv1Monday"), Target) Is Nothing Then
With Range("Adv1Monday")
.Copy Destination:=Sheets("Adventure 1").Range("C2")
If Not Intersect(Range("Adv2Monday"), Target) Is Nothing Then
With Range("Adv2Monday")
.Copy Destination:=Sheets("Adventure 2").Range("C2")
End With
End If
End With
End If
End Sub
Upvotes: 0
Views: 44
Reputation: 1642
If....end If and With...End with. They were not closed properly:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range"Adv1Monday"), Target) Is Nothing Then
With Range("Adv1Monday")
.Copy Destination:=Sheets("Adventure 1").Range("C2")
End With
End If
If Not Intersect(Range("Adv2Monday"), Target) Is Nothing Then
With Range("Adv2Monday")
.Copy Destination:=Sheets("Adventure 2").Range("C2")
End With
End If
End Sub
Upvotes: 2