Auto Archive

CJG19

New Member
Joined
Jul 12, 2021
Messages
40
Office Version
  1. 2010
Platform
  1. Windows
Good Morning,

I am trying to get rows on my spreadsheet to auto-archive when a column is changed to 'yes'. I have managed to adapt a macro from this forum, however it is getting to the code in red below and failing:

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Changed As Range
   
    Const YesCol As String = "P" '<- Your 'Yes' column
   
    Set Changed = Intersect(Target, Columns(YesCol))
    If Not Changed Is Nothing Then
        Application.EnableEvents = False
        Application.ScreenUpdating = False
        With Intersect(ActiveSheet.UsedRange, Columns(YesCol)).Offset(1)
            .AutoFilter Field:=1, Criteria1:="=YES"
            With .Offset(1).EntireRow
                .Copy Destination:=Sheets("Archived P3 2022 onwards") _
                    .Range("A" & Rows.Count).End(xlUp).Offset(1)
                .Delete
            End With
            .AutoFilter
        End With
        Application.EnableEvents = True
        Application.ScreenUpdating = True
    End If
End Sub

1656312950515.png


1656312991463.png


Could anyone please advise where I am going wrong?

TIA!

CJG19 :)
 
Last edited by a moderator:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,212,931
Messages
6,110,745
Members
448,295
Latest member
Uzair Tahir Khan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top