I am trying to auto-copy rows from a master worksheet to a separate worksheet. This occurs when a specific value is entered into Column B in a Master sheet. E.g. if ABC is entered into Column B in Master, these rows will get auto-copied into a separate sheet called ABC.
The issue is I have other values I want to copy into other worksheets. E.g if DEF is entered in Column B in Master, then auto-copy into separate sheet called DEF. I dont know how to do this.
The code below automatically copies all rows when Change is entered into Column B. This works fine but I also want to add another function that copies all rows when 'Delay' is entered.
Sub FilterAndCopy()
Dim rng As Range, sht1 As Worksheet, sht2 As Worksheet
Set sht1 = Worksheets("Master")
Set sht2 = Worksheets("Change")
sht2.UsedRange.ClearContents
With Intersect(sht1.Columns("B:BP"), sht1.UsedRange)
.Cells.EntireColumn.Hidden = False ' unhide columns
If .Parent.AutoFilterMode Then .Parent.AutoFilterMode = False
.AutoFilter field:=1, Criteria1:="Change"
.Range("A:F, BL:BO").Copy Destination:=sht2.Cells(4, "B")
.Parent.AutoFilterMode = False
.Range("H:BK").EntireColumn.Hidden = True ' hide columns
End With
End Sub
That code just copies Change rows from the master sheet to change sheet.
However I want to add another function that copies Delay rows from the master sheet to delay sheet. I'm just not sure if this can be incorporated into the code above? Or if I can do the following:
Sub FilterAndCopy()
Dim rng As Range, sht1 As Worksheet, sht3 As Worksheet
Set sht1 = Worksheets("Master")
Set sht3 = Worksheets("Delay")
sht3.UsedRange.ClearContents
With Intersect(sht1.Columns("B:BP"), sht1.UsedRange)
.Cells.EntireColumn.Hidden = False ' unhide columns
If .Parent.AutoFilterMode Then .Parent.AutoFilterMode = False
.AutoFilter field:=1, Criteria1:="Delay"
.Range("A:B, BJ:BO").Copy Destination:=sht2.Cells(4, "B")
.Parent.AutoFilterMode = False
.Range("D:BI").EntireColumn.Hidden = True ' hide columns
End With
End Sub
PLEASE NOTE: This macro has to be triggered without running a script.


