Autofilter for multiple sheets which may/may not have the data

abschy

New Member
Joined
Mar 20, 2019
Messages
31
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi all

Ive been having some errors with this part of my code in bold.

as i have this code run for 4 different sheets, each sheet will come back with different data, some sheets even with no data.

this code works fine on 1 sheet, and the rest keeps getting stuck at the bolded part even though the sheet has the data.

would really appreciate any help!!

Thank you!!

Code:
  ' get project name
   Worksheets("Find Project").Range("F8").Copy
    
     'filter projects
   Sheets("OPEX_OTHERS_DATA").Select
[B]   ActiveSheet.ListObjects("OPEX_OTHERS").Range.AutoFilter Field:=3, Criteria1 _[/B]
[B]        :=Sheets("Find Project").Range("F8")[/B]

    ' copy data without headers
    Range("OPEX_OTHERS[#All]").Offset(1, 0).Copy
    
    
    'paste data in project data sheet
    Sheets("Project Data").Activate
    Cells(1, 1).PasteSpecial xlPasteValues
    
    'unfilter data
    Worksheets("OPEX_OTHERS_DATA").Select
    Worksheets("OPEX_OTHERS_DATA").ShowAllData
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
What does the error message say?
I tested the code and it works for me in both ways with data in the table or without data.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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