Archive from a table

chris w

New Member
Joined
Feb 8, 2006
Messages
1
Hi, I want to archive some items which are in a table when I set their status to "complete". In my test workbook it orks fine using this code.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Changed As Range

Const YesCols As String = "M" '<- Your 'completed' columns

Set Changed = Intersect(Target, Columns(YesCols))
If Not Changed Is Nothing Then
Application.EnableEvents = False
Application.ScreenUpdating = False
With Intersect(ActiveSheet.UsedRange, Columns(YesCols))
.AutoFilter Field:=1, Criteria1:="=Completed"
With .Offset(1).EntireRow
.Copy Destination:=Sheets("ARCHIVE") _
.Range("A" & Rows.Count).End(xlUp).Offset(1)
.Delete
End With
.AutoFilter
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub

However, when I run this against the workbook which has the table in it I get "autofilter method of range class failed 1004" and despite whatever I try I can't make it work. Does anybody have any idea of how I can fix this?
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
The script works for me.
Do you have a sheet named
ARCHIVE
in the active workbook

Do you have any other auto sheet event scripts in this worksheet?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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