I have this code working at the moment
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("D2:D500")) Is Nothing Then
Application.EnableEvents = False 'Disables events to prevent endless loop
On Error GoTo Finalize 'Re-enable events
Target.Value = Application.VLookup(Target.Value, Me.Range("Q:R"), 2, False)
End If
Finalize:
Application.EnableEvents = True
End Sub
However, I'd like to change the vlookup source ("Q:R") to same the column but on another sheet ("Sheet2"). I have been trying to input Worksheet("Sheet2") any where in the code but I don't think I'm doing it correctly. Any ideas?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("D2:D500")) Is Nothing Then
Application.EnableEvents = False 'Disables events to prevent endless loop
On Error GoTo Finalize 'Re-enable events
Target.Value = Application.VLookup(Target.Value, Me.Range("Q:R"), 2, False)
End If
Finalize:
Application.EnableEvents = True
End Sub
However, I'd like to change the vlookup source ("Q:R") to same the column but on another sheet ("Sheet2"). I have been trying to input Worksheet("Sheet2") any where in the code but I don't think I'm doing it correctly. Any ideas?