Some basic code to go in the class module for the Catalog sheet:
Option Explicit
Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range
Dim BOMRow As Long
For Each r In Intersect(Target, Range("A:A"))
If r.Value = "x" Then
BOMRow = shtBOM.Cells(Rows.Count, 2).End(xlUp).Offset(1).Row
shtBOM.Cells(BOMRow, 2).Value = r.Offset(, 2).Value
shtBOM.Cells(BOMRow, 4).Value = r.Offset(, 3).Value
shtBOM.Cells(BOMRow, 10).Value = r.Offset(, 4).Value
ElseIf r.Value = vbNullString Then
Set r = shtBOM.Range("B:B").Find(What:=r.Offset(, 2).Value)
If Not r Is Nothing Then
r.EntireRow.Delete
End If
End If
Next
End Sub
Even though an updated workbook is attached, if you copy/paste that code make sure you include the 2 'Option' statements at the top of the code window as VBA is case sensitive by default.
Also, the code name for the BOM sheet has been changed from the VBA default. Comments in the code in the workbook.
Bookmarks