VBA filtering by multiple criteria shows error 1004

nickamongo

New Member
Joined
May 15, 2018
Messages
6
So I keep getting an error 1004 on this line when I want to filter a drop-down set from cell C4 - any ideas why?




Sub Update()


ActiveWorkbook.RefreshAll
Columns("L:L").EntireColumn.AutoFit
Selection.EntireColumn.Hidden = False
ActiveSheet.Range("$L$4").AutoFilter Field:=1, Criteria1:="FALSE"
ActiveSheet.Range("$C$4").AutoFilter Field:=1, Criteria1:=Array("1. Open", "2. Managed", "In Progress", "Not Started", "Status"), Operator:=xlFilterValues

End Sub
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,593
Office Version
  1. 2007
Platform
  1. Windows
So I keep getting an error 1004 on this line when I want to filter a drop-down set from cell C4 - any ideas why?

Sub Update()

ActiveWorkbook.RefreshAll
Columns("L:L").EntireColumn.AutoFit
Selection.EntireColumn.Hidden = False
ActiveSheet.Range("$L$4").AutoFilter Field:=1, Criteria1:="FALSE"
ActiveSheet.Range("$C$4").AutoFilter Field:=1, Criteria1:=Array("1. Open", "2. Managed", "In Progress", "Not Started", "Status"), Operator:=xlFilterValues

End Sub

I tried the code and I have no error.
Where do you have the data in C or in A?
You can put a sample of how your data is in the cells.
 

nickamongo

New Member
Joined
May 15, 2018
Messages
6
[B said:
ActiveSheet.Range("$C$4").AutoFilter Field:=1, Criteria1:=Array("1. Open", "2. Managed", "In Progress", "Not Started", "Status"), Operator:=xlFilterValues[/B][/U]

Data is in Column C. I tried canging the field to 3 but that hasn't changed anything.
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,593
Office Version
  1. 2007
Platform
  1. Windows
You could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.
 

nickamongo

New Member
Joined
May 15, 2018
Messages
6
You could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.

https://www.dropbox.com/s/fvuwnvpwihe3xe2/Example VBA.xlsm?dl=0

Now it seems to be failing at the name? (as I'm typing this I think there may be a space in the macro title though...)
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,593
Office Version
  1. 2007
Platform
  1. Windows
Apparently you can not filter with VBA when you have data from a pivot table in the same selection.


You will have to copy all the data to another sheet and make the filters with the information on the other sheet.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,383
Messages
5,528,377
Members
409,817
Latest member
JiNXX9500

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top