LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Triple Filter

I am trying to create some kind of synthetic triple filter. I was hoping to
enter up to three values into a UserForm, paste all three values into a
certain sheet, and then copy and paste an entire row from one sheet to
another sheet, when these three (or two or just one) criteria are met. First
I copy data from a sheet named 'Primary' and paste it into a sheet named
'Filter'. Below is what I have so far:


Private Sub CommandButton1_Click()
Sheets("Primary").Activate
Sheets("Primary").Select
Range("A1").Select

Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Filter").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Cells.Select
Selection.ClearContents
Range("A2").Select

Cells(2, 17) = TextBox1.Text
Cells(3, 17) = TextBox2.Text
Cells(4, 17) = TextBox3.Text

Sheets("Primary").Select
Dim i As Long
k = 1
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
For i = 1 To nLastRow
If copydata(i) Then
Set rc = Cells(i, 5).EntireRow
Set rd = Sheets("Primary").Cells(k, 1) '< -- I think the problem is
here
Sheets("Filter").Select '< -- I think there is a problem here too
rc.Copy rd
k = k + 1
End If
Next
Unload UserForm1
End Sub



Function copydata(i As Long) As Boolean
Dim Val1
Dim Val2
Dim Val3

Val1 = Range("Q2")
Val2 = Range("Q3")
Val3 = Range("Q4")


copydata = False
For j = 1 To Columns.Count
If Cells(i, j).Text = Val1 Then
copydata = True
Exit Function
End If
Next
End Function


It was working fine with one criteria, but then I made some changes, to
accommodate the three items, and now nothing works. Is it even possible to
do what I propose? If so, how?


Regards,
Ryan--


--
RyGuy
 
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
Triple lookup? Andy the Yeti Excel Worksheet Functions 6 October 3rd 06 02:43 PM
Apologies for triple post Janev New Users to Excel 2 September 22nd 06 08:56 PM
Triple Criteria Formula HonorsOA Excel Programming 1 September 21st 06 03:47 PM
Triple Quotes when saving to *.csv D Excel Discussion (Misc queries) 2 December 4th 05 06:06 AM
Triple occurence formula toyota58 Excel Worksheet Functions 1 August 19th 05 10:43 AM


All times are GMT +1. The time now is 04:02 PM.

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"