1004 Error when using an array for auto-filter criteria

bcrpanther

New Member
Joined
Jul 28, 2015
Messages
3
Hello to all,
I'm getting a 1004 error when trying to apply a autofilter using a array. Bellow is the line of code in question:


Worksheets(CONBaselineSheet).Range("A1:" & GetColumnLetter(CONLastTaskColumn) & GBLProjectFile.TotalTasks + 1).AutoFilter Field:=varField.Field, Criteria1:=varField.Values, Operator:=xlFilterValues


Variable values:

Range => "A1:" & GetColumnLetter(CONLastTaskColumn) & GBLProjectFile.TotalTasks + 1 equates to => "A2:AB1250"
varField.field => 6 and I varified that the field exsists
varValues is a variant array with 2 values "SHS", "LT"


Any Ideas?

Thanks!!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Welcome to the board. I think your Criteria1:=varField.Values should be Criteria1:=varValues

Try
Code:
With Worksheets(CONBaselineSheet).Range("A1:" & GetColumnLetter(CONLastTaskColumn) & GBLProjectFile.TotalTasks + 1)
  .AutoFilter Field:=varField.Field, _
  Criteria1:=varValues, _
  Operator:=xlFilterValues
End With
 
Upvote 0
Welcome to the board. I think your Criteria1:=varField.Values should be Criteria1:=varValues

Try
Code:
With Worksheets(CONBaselineSheet).Range("A1:" & GetColumnLetter(CONLastTaskColumn) & GBLProjectFile.TotalTasks + 1)
  .AutoFilter Field:=varField.Field, _
  Criteria1:=varValues, _
  Operator:=xlFilterValues
End With

Thanks JackDanIce for the reply... varField is a class module with a procedure called values (which is a declared as as a string Array. ) I have tried to just use the Array statement with static values just see it work, but I still get the same 1004 error. I'm sure is it something simple that I'm missing


 
Upvote 0
What exactly does varField.Values return?
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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