Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Filter problem

A combobox contains the following code:

Private Sub cbCAT_Change()
Filtercolumn = 12
If cbCAT < "" Then
Selection.AutoFilter Field:=Filtercolumn, Criteria1:="=" &
cbCAT
Else
Selection.auofilter Field:=Filtercolumn
End If

End Sub

Problem
When cbCAT < "" then a filter is set according to the value of cbCAT.
That works just fine.

When the user blanks the value and cbCAT = "" I want to set the filter
off. When I do it manually in the worksheet, it works fine. However,
then I do it here in the macro, I get an error message.

Anybody know whe?

Glen

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Filter problem

Maybe explicitly specifying the worksheet would help:

If cbCat < "" Then
Worksheets("sheet1").AutoFilter.Range.AutoFilter _
Field:=FilterColumn, Criteria1:="=" & cbCat
Else
Worksheets("sheet1").AutoFilter.Range.AutoFilter Field:=FilterColumn
End If

=====
If that doesn't help...

Where is this combobox?
If it's on a worksheet, how do you populate it?
Do you use a linkedcell and/or listfillrange?


wrote:

A combobox contains the following code:

Private Sub cbCAT_Change()
Filtercolumn = 12
If cbCAT < "" Then
Selection.AutoFilter Field:=Filtercolumn, Criteria1:="=" &
cbCAT
Else
Selection.auofilter Field:=Filtercolumn
End If

End Sub

Problem
When cbCAT < "" then a filter is set according to the value of cbCAT.
That works just fine.

When the user blanks the value and cbCAT = "" I want to set the filter
off. When I do it manually in the worksheet, it works fine. However,
then I do it here in the macro, I get an error message.

Anybody know whe?

Glen


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Filter problem

Dave,
Thanks for the help. That works great! What I don't understand is
why?
In the user form I select the sheet I want to filter during the form
activate event.

Anyway, it worked. Thanks again.

Glen

Dave Peterson wrote:
Maybe explicitly specifying the worksheet would help:

If cbCat < "" Then
Worksheets("sheet1").AutoFilter.Range.AutoFilter _
Field:=FilterColumn, Criteria1:="=" & cbCat
Else
Worksheets("sheet1").AutoFilter.Range.AutoFilter Field:=FilterColumn
End If

=====
If that doesn't help...

Where is this combobox?
If it's on a worksheet, how do you populate it?
Do you use a linkedcell and/or listfillrange?


wrote:

A combobox contains the following code:

Private Sub cbCAT_Change()
Filtercolumn = 12
If cbCAT < "" Then
Selection.AutoFilter Field:=Filtercolumn, Criteria1:="=" &
cbCAT
Else
Selection.auofilter Field:=Filtercolumn
End If

End Sub

Problem
When cbCAT < "" then a filter is set according to the value of cbCAT.
That works just fine.

When the user blanks the value and cbCAT = "" I want to set the filter
off. When I do it manually in the worksheet, it works fine. However,
then I do it here in the macro, I get an error message.

Anybody know whe?

Glen


--

Dave Peterson


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter problem Ray[_7_] Excel Worksheet Functions 1 June 22nd 11 01:15 AM
Filter problem Ray[_7_] New Users to Excel 1 June 22nd 11 12:25 AM
Filter problem law Excel Discussion (Misc queries) 2 December 1st 07 03:43 PM
problem with filter Pascale Excel Discussion (Misc queries) 5 June 5th 07 04:28 PM
Filter problem [email protected] Excel Worksheet Functions 1 November 28th 05 09:10 PM


All times are GMT +1. The time now is 11:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"