WARNING. This code will disable UNDO. If you go this route to save worksheet space, the undo will be disabled on the orders worksheet.
When something in col B (and the row is >4) is entered the formulas will be created in Col F,G, H of those rows.
Code: Select all
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rCell As Range
Dim rInt As Range
Set rInt = Intersect(Target, Range("B:B"))
If Not rInt Is Nothing Then
Application.EnableEvents = False
For Each rCell In rInt
If rCell.Row > 4 Then
rCell.Offset(0, 4).FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-4]&"" ""&RC[-3],Previous!R18C5:R37C15,9,0))" & _
", """", VLOOKUP(RC[-4]&"" ""&RC[-3],Previous!R18C5:R37C15,9,0))"
rCell.Offset(0, 5).FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-5]&"" ""&RC[-4],Previous!R18C5:R37C15,9,0))" & _
", """", VLOOKUP(RC[-5]&"" ""&RC[-4],Previous!R18C5:R37C15,10,0))"
rCell.Offset(0, 6).FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-6]&"" ""&RC[-5],Previous!R18C5:R37C15,9,0))" & _
", """", VLOOKUP(RC[-6]&"" ""&RC[-5],Previous!R18C5:R37C15,11,0))"
End If
Next
End If
Application.EnableEvents = True
Set rCell = Nothing
Set rInt = Nothing
End Sub