mikeoly
06-13-2019, 12:16 PM
Hi Everyone!
I have some code that does what I want, but if you change the entire 'Target' range at once, it takes a while to cycle through. Any thoughts on how to circumvent the 'For' loop, or optimize in another way?
Thank you in advance!
Private Sub worksheet_change(ByVal Target As Range)
For i = 26 To 40
If Not Intersect(Target, Me.Range("B" & i)) Is Nothing Then
Worksheets("Primary").Range("$c$" & i & ":$f$" & i).Formula = "=IF(B" & i & "="""","""",VLOOKUP(B" & i & ",Class,2,FALSE))"
End If
Next
End Sub
I have some code that does what I want, but if you change the entire 'Target' range at once, it takes a while to cycle through. Any thoughts on how to circumvent the 'For' loop, or optimize in another way?
Thank you in advance!
Private Sub worksheet_change(ByVal Target As Range)
For i = 26 To 40
If Not Intersect(Target, Me.Range("B" & i)) Is Nothing Then
Worksheets("Primary").Range("$c$" & i & ":$f$" & i).Formula = "=IF(B" & i & "="""","""",VLOOKUP(B" & i & ",Class,2,FALSE))"
End If
Next
End Sub