MatthewField
New Member
- Joined
- Jan 5, 2018
- Messages
- 8
Good morning,
I have the following code in my excel sheet, however if i update the range table (In bold below) for the VLOOKUP then the code stops working and I have no clue why it's happening or how to stop it. The range table needs to have the flexibility of having new additions added to it.
The code is as follows:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.CountLarge > 1 Then Exit Sub
If Target.Column = 2 Then
Target.Offset(, 1).FormulaR1C1 = "=VLOOKUP(rc[-1], Fields!r4c2:r23c3, 2, FALSE)"
ElseIf Target.Column = 7 Then
Target.Offset(, 1).FormulaR1C1 = "=VLOOKUP(rc[-1], Fields!r4c6:r79c7, 2, FALSE)"
End If
Application.EnableEvents = True
End Sub
Could anyone possibly help?
Many thanks,
I have the following code in my excel sheet, however if i update the range table (In bold below) for the VLOOKUP then the code stops working and I have no clue why it's happening or how to stop it. The range table needs to have the flexibility of having new additions added to it.
The code is as follows:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.CountLarge > 1 Then Exit Sub
If Target.Column = 2 Then
Target.Offset(, 1).FormulaR1C1 = "=VLOOKUP(rc[-1], Fields!r4c2:r23c3, 2, FALSE)"
ElseIf Target.Column = 7 Then
Target.Offset(, 1).FormulaR1C1 = "=VLOOKUP(rc[-1], Fields!r4c6:r79c7, 2, FALSE)"
End If
Application.EnableEvents = True
End Sub
Could anyone possibly help?
Many thanks,