Re: copy data to new sheet based on condition
This procedure will run each time a catalog Multiple is changed. It clears the invoice items and rebuilds them with each change.
Put it in the Catalog module. To clear the invoice simply clear the Catalog multiple column. To remove an item change the Catalog multiple to zero or null.
Code
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
If Target.Column = 7 Then
Sheet5.Range("B25:F40").ClearContents
For Each c In Range("G2", Cells(Rows.Count, "G").End(xlUp))
If c = 0 Then c = ""
If c <> 0 Then
With Sheets("Invoice")
.Range("B40").End(xlUp).Offset(1, 0) = c.Offset(, -3)
.Range("D40").End(xlUp).Offset(1, 0) = c.Offset(, -2)
.Range("E40").End(xlUp).Offset(1, 0) = c
.Range("F40").End(xlUp).Offset(1, 0) = c.Offset(, 1)
End With
End If
Next c
End If
End Sub
Display More