Filter button keeps getting deleted

D_Holmes

New Member
Joined
Sep 18, 2020
Messages
32
Office Version
  1. 2013
Platform
  1. Windows
Hi All,

I am trying to run a macro that will autofilter my table and then copy the filtered data to another sheet. However, when the macro gets to a specific part of the code, I get an error message and then realize that its because the filter button under one of the filter options is deleted. When it deletes, the macro has no way of filtering the information in the column. Can someone look at my macro and let me know what I am doing wrong? Thanks.

'Paste HCH HCH PATIENT ACCESS
Rich (BB code):
Next6:
Worksheets("Disaster110220").Range("A1:P1").AutoFilter Field:=14, Criteria1:="HCH HCH PATIENT ACCESS"
Worksheets("Disaster110220").Range("A1:P1").AutoFilter Field:=9, Criteria1:="ACTIVE"

    Worksheets("Disaster110220").Range("a2:p" & lr).SpecialCells(xlCellTypeVisible).Copy
    Worksheets("HCH HCH PATIENT ACCESS").Range("a2").PasteSpecial Paste:=xlPasteAll
    Application.CutCopyMode = False

Worksheets("Disaster110220").Range("A1:P1").AutoFilter Field:=9, Criteria1:="ONCALL", VisibleDropDown:=False

On Error GoTo Next7

    Worksheets("Disaster110220").Range("a2:p" & lr).SpecialCells(xlCellTypeVisible).Copy
    Worksheets("HCH HCH PATIENT ACCESS").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteAll
    Application.CutCopyMode = False

Next7:
Worksheets("Disaster110220").Range("A1:P1").AutoFilter Field:=9, Criteria1:="LEAVE", VisibleDropDown:=False

On Error GoTo Next8

   Worksheets("Disaster110220").Range("a2:p" & lr).SpecialCells(xlCellTypeVisible).Copy (I get the error here, however the code is the same for all subsequent sections)
    Worksheets("HCH HCH PATIENT ACCESS").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteAll
    Application.CutCopyMode = False
 
Last edited by a moderator:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,884
Messages
6,122,082
Members
449,064
Latest member
MattDRT

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