VB and Advanced Filter

  • Thread starter Thread starter Carrie_Loos via OfficeKB.com
  • Start date Start date
C

Carrie_Loos via OfficeKB.com

Hi -

Is there a way to state a criteron range in an advanced filter? I cannot
figure out the syntax if there is. Please see below on the filter as I have
placed a "Range" in the filter that obviously doesn't work but is there a way
to make it work?

Thanks
Carrie

Private Sub ListBox1_Click()

Dim UserInput As Range
Dim UserInput2 As Range

Set UserInput = Worksheets("Keys").Range("K9")
Set UserInput2 = Worksheets("Keys").Range("K10")

Range("UserInput") = ListBox1.Value
For i = 1 To ListBox1.ListCount - 1
Range("UserInput2") = ListBox1.Selected(i)
Next

Sheets("Classes").Select
Selection.AutoFilter Field:=6, Criteria1:="Range.UserInput", Operator:
=xlAnd
 
Private Sub ListBox1_Click()

Dim UserInput As Range
Dim UserInput2 As Range

Set UserInput = Worksheets("Keys").Range("K9")
Set UserInput2 = Worksheets("Keys").Range("K10")

UserInput.Value = ListBox1.Value
For i = 1 To ListBox1.ListCount - 1
Range("UserInput2") = ListBox1.Selected(i)
Next

Sheets("Classes").Select
Selection.AutoFilter Field:=6, Criteria1:=UserInput, Operator:=xlAnd


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Oh my gosh - Do I feel silly! I thought I had already tried thatThanks for
your help.

Bob said:
Private Sub ListBox1_Click()!

Dim UserInput As Range
Dim UserInput2 As Range

Set UserInput = Worksheets("Keys").Range("K9")
Set UserInput2 = Worksheets("Keys").Range("K10")

UserInput.Value = ListBox1.Value
For i = 1 To ListBox1.ListCount - 1
Range("UserInput2") = ListBox1.Selected(i)
Next

Sheets("Classes").Select
Selection.AutoFilter Field:=6, Criteria1:=UserInput, Operator:=xlAnd
[quoted text clipped - 24 lines]
Selection.AutoFilter Field:=6, Criteria1:="Range.UserInput", Operator:
=xlAnd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top