PC Review


Reply
Thread Tools Rate Thread

2 parrameters to filter

 
 
Eric
Guest
Posts: n/a
 
      24th Jan 2008
Hello all,

Here is macro for my sheet to do a filter search with one parrameter "Mix
Type". Now I want it to search by 2 criterias first is "Mix Type" second is
"Contract #" and I want this to be done anytime a search is done. Any help
would be appreciated.

ERic

Sub RemoveDuplicates_Mix_Type()

Dim allcells As Range, cell As Range
Dim nodupes As New Collection

On Error Resume Next
For Each cell In Range("B27:B500")
nodupes.Add cell.Value, CStr(cell.Value)
Next cell
On Error GoTo 0

For Each item In nodupes
UserForm3.ListBox1.AddItem item
Next item

UserForm3.Show

Sheets("test Database").Select
Range("A1").Value = 1

Sheets("test Database_mix").Select
Range("B2").Value = 1


Then in the list box is:

Private Sub ListBox1_Click()

Range("d6").Value = ListBox1


For i = 0 To UserForm3.ListBox1.ListCount - 1
If UserForm3.ListBox1.Selected(i) Then

Dim ws As Worksheet
Dim rng As Range
Dim rng2 As Range

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

Set ws = Sheets("Test Database")

Set rng = ws.Range("B26:AG500")

ws.AutoFilterMode = False

rng.AutoFilter field:=1, Criteria1:="=" & ws.Range("D6").Value

ws.AutoFilter.Range.Copy


Sheets("test database_mix").Select

Range("C500").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, -2).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

ws.AutoFilterMode = False

With Application
.ScreenUpdating = True
.EnableEvents = True
End With

End If
Next


End Sub



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter unbound search combo box based on filter in form's OnOpenEvent miatadiablo@gmail.com Microsoft Access Form Coding 3 1st Jun 2009 02:24 PM
Passing parrameters when calling a sub from by clicking an object =?Utf-8?B?QmFsbWFpbiBCdXNod2Fsa2Vy?= Microsoft Excel Programming 0 25th Oct 2007 01:13 AM
Junk Filter waits til I select an email to filter it in IMAP accou =?Utf-8?B?Sm9lbCBC?= Microsoft Outlook Discussion 3 2nd Oct 2006 12:50 PM
List Box used to filter a report in print preview, when make more than one selection it does not filter the selections. Incolor Microsoft Access Forms 2 25th Apr 2006 04:20 PM
Use input box to make filter choice while providing list of possible filter choices GretOgrady Microsoft Excel Discussion 3 20th May 2005 12:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:03 PM.