Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default User Form to Filter by Multiple Criteria

Good day,

I need to create a User Form (Excel 2003) that allows users to enter 5
filter criteria. Each filter must allow input for a single Column letter
(e.g., A, B, C), single operand (e.g., =, , <, ) and single criteria (e.g.,
A1500, 100.00).

Any suggestions? I tried building a filter string (shown below).

*****
Dim strField1 As String, ...

'Filter 1
strFilter = IIf(Me.txtField1.Value = "", "", _
".AutoFilter Field:=" & Me.txtField1.Value & ", " & _
"Criteria:='" & Me.cboOperand1.Value & Me.txtValue1.Value & "'")

'Filter 2
strFilter = IIf(Me.txtField2.Value = "", strFilter, _
strFilter & ", Operator:=xlAnd .AutoFilter Field:=" & Me.txtField2.Value
& ", " & _
"Criteria:='" & Me.cboOperand2.Value & Me.txtValue2.Value & "'")

'(same code for Filters 3, 4, and 5)

'Run the filter
If strFilter = "" Then
MsgBox "You must enter at least one filter."
GoTo Exit_Sub
Else
Set rng = ActiveSheet.AutoFilter.Range
With rng
strFilter
End With
End If

'Exit sub
Exit_Sub:
Exit Sub

'Error handler
Err_Handler:
MsgBox "Error: " & Err
GoTo Exit_Sub

End Sub

*****

Regards,

Dan

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 Multiple Columns on Multiple Criteria and count the last co LBitler Excel Worksheet Functions 2 February 12th 09 08:36 PM
User form to change manual field filter in pivot table bennyob Excel Discussion (Misc queries) 0 March 7th 07 01:00 PM
Filter Excel Pivot, based on user entry form Jayco Excel Discussion (Misc queries) 1 August 16th 06 06:07 PM
Filter Listbox in user form Nikki[_3_] Excel Programming 0 August 29th 04 12:23 AM
User form search criteria example Tom Ogilvy Excel Programming 0 July 27th 04 05:54 PM


All times are GMT +1. The time now is 12:27 AM.

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

About Us

"It's about Microsoft Excel"