AutoFilter Criteria Field in VBA

Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: AutoFilter Criteria Field in VBA

  1. #1
    New Member
    Join Date
    Jun 2002
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    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

  2. #2

    Join Date
    May 2002
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    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")

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com