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
Dim CostCenter As String
Selection.AutoFilter Field:=1, criteria1:= CostCenter