Juan Jacobs
New Member
I have created a vba code which copies data from the main sheet to a new sheet depending on a specific cell "Status". If Status is set to active then that particular row is copied and pasted to a new sheet called active. If the status is changed to inactive then that specific row copies and pastes to a new worksheet called inactive.
I have not yet found a way to remove the row from the copied sheet if the status is changed to something else on the main sheet.
My main issue is that I would like to insert a slicer which allows the user to choose the province of the member first.
Once the province is selected, I then need the row to be copied to the new worksheet once the user changes the members status.
The code is below:
>>> use code - tags <<<
I have not yet found a way to remove the row from the copied sheet if the status is changed to something else on the main sheet.
My main issue is that I would like to insert a slicer which allows the user to choose the province of the member first.
Once the province is selected, I then need the row to be copied to the new worksheet once the user changes the members status.
The code is below:
>>> use code - tags <<<
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Dim lngLastRow As Long
Dim ActiveSheet As Worksheet, InactiveSheet As Worksheet, PendingSheet As Worksheet, RenewedSheet As Worksheet, FollowUpSheet As Worksheet, RedZoneSheet As Worksheet
Set ActiveSheet = Sheets("Active")
Set InactiveSheet = Sheets("Inactive")
Set PendingSheet = Sheets("Pending")
Set RenewedSheet = Sheets("Renewed")
Set FollowUpSheet = Sheets("Follow Up")
Set RedZoneSheet = Sheets("Red Zone")
lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
With Range("A5", "R" & lngLastRow)
.AutoFilter
.AutoFilter Field:=4, Criteria1:="Active"
.Copy ActiveSheet.Range("A1")
.AutoFilter Field:=4, Criteria1:="Inactive"
.Copy InactiveSheet.Range("A1")
.AutoFilter Field:=4, Criteria1:="Pending"
.Copy PendingSheet.Range("A1")
.AutoFilter Field:=4, Criteria1:="Renewed"
.Copy RenewedSheet.Range("A1")
.AutoFilter Field:=4, Criteria1:="Follow Up"
.Copy FollowUpSheet.Range("A1")
.AutoFilter Field:=4, Criteria1:="Red Zone"
.Copy RedZoneSheet.Range("A1")
.AutoFilter
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub
Last edited by a moderator: