Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Developing a code that uses a combobox for an autofilter criteria

I am developing a program using Visual Basic on Excel to automate the filter
function. Excel has its autofilter option but I created a userform with a
combobox and a command button and the idea is to type the filter criteria
(Example: I type pumps) onto the combobox so that on clicking the command
button, it automatically filters the specified item. I have a list of items
on a worksheet, about 700 items. Unfortunately, I'm unable to link the
criteria to the user specified filter item (via the combobox). My code isn't
working. I tried first with a textbox and switched to a combobox but it isn't
working.
How do I link a combobox so that it filters the user-inputted item?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Developing a code that uses a combobox for an autofilter criteria

If i understand you correctply, you are working in VBA in Excel

I assume that your data are in columns A, B, C and D and in rows 4 to
..... (you can change it in MakeFilter sub in ARange and after clearing
filters
On form i have one combo box and one command button (just to activate
filters.
General idea is using Excel's own filter system
All you had to do is deactivate filters (ClearFilter sub) before you
apply new one (this sub)

here are subs...


Public Sub MakeFilter()
Dim flt As String
Dim MaxRow
Dim ARange As Range

Set ARange = Range("A4:A65535")
MaxRow = 65535 - WorksheetFunction.CountBlank(ARange) 'This is last used
row i assume there is no blank cells in this column

ClearFilter 'Filter must be disabled before activating new one...
Range("A3:D" & MaxRow).Select 'Must start one row before data
Selection.AutoFilter Field:=2, Criteria1:="=*" & ComboBox1.Text &
"*", VisibleDropDown:=True
Cells(1, 1).Select
End Sub


Public Sub ClearFilter()

On Error Resume Next
If ActiveSheet.AutoFilterMode Then
ActiveSheet.Cells.AutoFilter
End If

End Sub


Private Sub CommandButton1_Click()
MakeFilter
End Sub



On 10.02.2010 14:37, Bebe_dash wrote:
I am developing a program using Visual Basic on Excel to automate the filter
function. Excel has its autofilter option but I created a userform with a
combobox and a command button and the idea is to type the filter criteria
(Example: I type pumps) onto the combobox so that on clicking the command
button, it automatically filters the specified item. I have a list of items
on a worksheet, about 700 items. Unfortunately, I'm unable to link the
criteria to the user specified filter item (via the combobox). My code isn't
working. I tried first with a textbox and switched to a combobox but it isn't
working.
How do I link a combobox so that it filters the user-inputted item?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Developing a code that uses a combobox for an autofilter criteria

Also combobox on form should pu combobox with parameters

frmFilter.ComboBox1.RowSource = "B4:B" & 65535 -
WorksheetFunction.CountBlank(Range("A4:A65535"))

frmFilter.ComboBox1.ControlSource = "B4"

With this paramters combobox will be filled with data in columns B from
first row (row 4 in example) till last filled row
you can combine this with sub from my last reply

On 10.02.2010 14:37, Bebe_dash wrote:
I am developing a program using Visual Basic on Excel to automate the filter
function. Excel has its autofilter option but I created a userform with a
combobox and a command button and the idea is to type the filter criteria
(Example: I type pumps) onto the combobox so that on clicking the command
button, it automatically filters the specified item. I have a list of items
on a worksheet, about 700 items. Unfortunately, I'm unable to link the
criteria to the user specified filter item (via the combobox). My code isn't
working. I tried first with a textbox and switched to a combobox but it isn't
working.
How do I link a combobox so that it filters the user-inputted item?

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
Autofilter by combobox selection CBartman Excel Programming 1 October 14th 09 12:42 PM
Selection.AutoFilter Field / Criteria = criteria sometimes non-existing on worksheet markx Excel Programming 1 November 24th 06 02:52 PM
Make Combobox act like autofilter andrewbears Excel Programming 1 January 4th 05 05:57 PM
VBA question - autofilter combobox ajliaks[_11_] Excel Programming 2 April 17th 04 12:21 PM
Code to allow user to enter criteria for autofilter Ron McCormick[_2_] Excel Programming 4 December 1st 03 12:03 PM


All times are GMT +1. The time now is 11:58 AM.

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"