You have to assign a value to Cost Center.
Or, if CostCenter is a named range, it does not have to be "dimmed" and the code would be :-
Selection.AutoFilter Field:=1, Criteria1:=Range("CostCenter")
This is a discussion on AutoFilter Criteria Field in VBA within the Excel Questions forums, part of the Question Forums category; I've recording an autofilter macro, then trying to add additional code in VBA . I'm trying to set the 'criteria' ...
I've recording an autofilter macro, then trying to add additional code in VBA. I'm trying to set the 'criteria' field to a data value - see following code - but VBA gives an error. Is there any way to force the criteria field to be want you want it to without hard-coding values??
Dim CostCenter As String
Selection.AutoFilter Field:=1, criteria1:= CostCenter
You have to assign a value to Cost Center.
Or, if CostCenter is a named range, it does not have to be "dimmed" and the code would be :-
Selection.AutoFilter Field:=1, Criteria1:=Range("CostCenter")
Bookmarks