Can someone explain what the error "variable not defined" means I have this code on my sheet:
In the VBA window it's telling me that 'variable j is undefined' I not sure I see how define it correctly; otherwise the code should do what I need it to do.
Code:
Private Sub WorkSheet_Change(ByVal Target As Range)
With Sheets("Sheet1")
j = 2
For i = 10 To 41
If UCase(.Range("M" & i).Text) = "Yes" Then
.Range("F" & i).Copy
Sheets("Sheet7").Range("A" & j).PasteSpecial Paste:=xlPasteValues
j = j + 1
End If
Next i
If Intersect(Target, .Range("B:B")) Is Nothing Or Target.Cells.Count > 1 Then
Exit Sub
Else
Target.Offset(, 1).Value = Date
Target.Offset(, 2).Value = Time
Target.Offset(, 15).Formula = "=$J$7"
Target.Offset(, 24).Formula = "=$J$7"
End If
End With
End Sub
In the VBA window it's telling me that 'variable j is undefined' I not sure I see how define it correctly; otherwise the code should do what I need it to do.