filter problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hiya,

I have a combobox (not the form one) set up with three options - from the selection it will action a filter in one column. For some reason the on-change code isn't working. Can anyone tell me why not/how to get it to work?

cells a6-a8 are the combobox listfillrange
cell a4 is the linked cell
the error is given as run-time '1004' Autofilter method of range class failed.

The autofilter arrow only exists on cell a5.

Here is the code:

Private Sub ComboBox1_Change()

Dim StatusSelected As String

StatusSelected = Range("A4").Value 'For some reason it won't accept .Text
Range("A5").AutoFilter Field:=1, Criteria1:="=" & Left(StatusSelected, 5) & "*"

End Sub

Thanks loads,

Basil
 
Try adding the line

Activecell.Activate

before you run the autofilter, it could be that the
combobox has the active focus. On a command button thereis
a property TakeFocusOnClick which can be set to False but
I don't think there is one for combo boxes.
-----Original Message-----
Hiya,

I have a combobox (not the form one) set up with three
options - from the selection it will action a filter in
one column. For some reason the on-change code isn't
working. Can anyone tell me why not/how to get it to work?
 
Genius

So simple, I've spent about 15 hours trying to get around the problem. Thankyou so much

Ba

----- Gavin wrote: ----

Try adding the lin

Activecell.Activat

before you run the autofilter, it could be that the
combobox has the active focus. On a command button thereis
a property TakeFocusOnClick which can be set to False but
I don't think there is one for combo boxes
-----Original Message----
Hiya
options - from the selection it will action a filter in
one column. For some reason the on-change code isn't
working. Can anyone tell me why not/how to get it to work
 
Back
Top