PC Review


Reply
Thread Tools Rate Thread

Creteria Help

 
 
=?Utf-8?B?VHJldmVyIEI=?=
Guest
Posts: n/a
 
      8th Mar 2007
Hi,

Thanks in advance

The following code is set for Creteria1 to = "A" how do I make it for A, B
or C

With Worksheets("Panel Details").Range("A1:IV2500")
.AutoFilter Field:=1, Criteria1:="A"
.SpecialCells(xlCellTypeVisible).Copy _
Worksheets("SS A").Cells(1, 1)
.AutoFilter
End With


Thanks again

Trev
 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      8th Mar 2007
Trev,
Maybe this will help:
http://www.meadinkent.co.uk/xlfilter.htm

Record a macro whilst you do this to generate the code.

NickHK

"Trever B" <(E-Mail Removed)> wrote in message
news:3DCB10D1-3D54-485F-A5C5-(E-Mail Removed)...
> Hi,
>
> Thanks in advance
>
> The following code is set for Creteria1 to = "A" how do I make it for A, B
> or C
>
> With Worksheets("Panel Details").Range("A1:IV2500")
> .AutoFilter Field:=1, Criteria1:="A"
> .SpecialCells(xlCellTypeVisible).Copy _
> Worksheets("SS A").Cells(1, 1)
> .AutoFilter
> End With
>
>
> Thanks again
>
> Trev



 
Reply With Quote
 
=?Utf-8?B?VHJldmVyIEI=?=
Guest
Posts: n/a
 
      8th Mar 2007
Thanks Nick,

Not much help

It does not help me how to input multi creteria,

Have tried:-
1) = "A" and "B" and "C"
2) = "A" or "B" or "C"

Tried recording a macro but still need help on criteria

Don't know what else to try.

Hope someone else can help.

Trev



"NickHK" wrote:

> Trev,
> Maybe this will help:
> http://www.meadinkent.co.uk/xlfilter.htm
>
> Record a macro whilst you do this to generate the code.
>
> NickHK
>
> "Trever B" <(E-Mail Removed)> wrote in message
> news:3DCB10D1-3D54-485F-A5C5-(E-Mail Removed)...
> > Hi,
> >
> > Thanks in advance
> >
> > The following code is set for Creteria1 to = "A" how do I make it for A, B
> > or C
> >
> > With Worksheets("Panel Details").Range("A1:IV2500")
> > .AutoFilter Field:=1, Criteria1:="A"
> > .SpecialCells(xlCellTypeVisible).Copy _
> > Worksheets("SS A").Cells(1, 1)
> > .AutoFilter
> > End With
> >
> >
> > Thanks again
> >
> > Trev

>
>
>

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      8th Mar 2007
Did you read this section ?
<Quote>
a single item (e.g. 'SMITH') underneath one of the fields
more than one criteria item in a single row - applies an 'AND' rule (e.g.
'SMITH' and 'XN41')
more than one criteria on different rows - applies an 'OR' rule (e.g. 'XN41'
or '<1500')
</Quote>
So you have to create your criteria in a column of
A
B
C

NickHK

"Trever B" <(E-Mail Removed)> wrote in message
news:07DB491A-7444-40EE-96A1-(E-Mail Removed)...
> Thanks Nick,
>
> Not much help
>
> It does not help me how to input multi creteria,
>
> Have tried:-
> 1) = "A" and "B" and "C"
> 2) = "A" or "B" or "C"
>
> Tried recording a macro but still need help on criteria
>
> Don't know what else to try.
>
> Hope someone else can help.
>
> Trev
>
>
>
> "NickHK" wrote:
>
> > Trev,
> > Maybe this will help:
> > http://www.meadinkent.co.uk/xlfilter.htm
> >
> > Record a macro whilst you do this to generate the code.
> >
> > NickHK
> >
> > "Trever B" <(E-Mail Removed)> wrote in message
> > news:3DCB10D1-3D54-485F-A5C5-(E-Mail Removed)...
> > > Hi,
> > >
> > > Thanks in advance
> > >
> > > The following code is set for Creteria1 to = "A" how do I make it for

A, B
> > > or C
> > >
> > > With Worksheets("Panel Details").Range("A1:IV2500")
> > > .AutoFilter Field:=1, Criteria1:="A"
> > > .SpecialCells(xlCellTypeVisible).Copy _
> > > Worksheets("SS A").Cells(1, 1)
> > > .AutoFilter
> > > End With
> > >
> > >
> > > Thanks again
> > >
> > > Trev

> >
> >
> >



 
Reply With Quote
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      8th Mar 2007
Hi
Autofilter only lets you filter on two criteria at most. For 3
criteria you need advanced filter.
I'll assume you are selecting your criteria from a multiselect
listbox. If not, this should give you a start

Private Sub OKButton_Click()
Dim Grouplistdata As New Collection
Dim i As Integer, GroupCount As Integer
Dim Item As Variant
Dim GroupCriteria As Range

Application.ScreenUpdating = False
With RegGroups.GroupList
'Get the data in the GroupList ListBox
For i = 0 To .ListCount - 1
'for each Group in the list
If .Selected(i) Then
Grouplistdata.Add .List(i)
End If
Next i
End With

GroupCount = Grouplistdata.Count
'Remove any filter present
With Worksheets("Panel Details")
On Error Resume Next 'required if Advanced filter used
.ShowAllData
On Error GoTo 0
.AutoFilterMode = False 'Removes drop down arrows
End With
Select Case GroupCount
'Check the user hasn't clicked OK on the ViewList userform without
selecting anything
Case 0
Exit Sub 'nothing happens and form is still visible
'Use AutoFilter if GroupCount is 1 or 2
Case 1
Worksheets("Panel Details").Range("A1:IV2500").AutoFilter
Field:=1, Criteria1:=CStr(Grouplistdata(1))
Case 2
Worksheets("Panel Details").Range("A1:IV2500").AutoFilter
Field:=1, Criteria1:=CStr(Grouplistdata(1)), Operator:=xlOr,
Criteria2:=CStr(Grouplistdata(2))
Case Is > 2
'Start by inserting a worksheet and creating a Criteria Range to put
into AdvancedFilter
'addSheet first removes the sheet, so it is always a fresh sheet
AddSheet "WorkSpaceSheet" 'now the active sheet
With ActiveWorkbook.Worksheets("WorkSpaceSheet")
.Visible = False
.Cells(1, 1).Value = "Group" 'same as heading on worksheet
for "A", "B", "C",..
i = 1 'set a counter and put group items below "Group"
For Each Item In Grouplistdata
i = i + 1
.Cells(i, 1).Value = Item
Next Item

Set GroupCriteria = .Cells(1, 1).CurrentRegion
End With 'worksheet
'Filter the list
With Worksheets("Panel Details")
.Activate
.Range("A1:IV2500").AdvancedFilter
Action:=xlFilterInPlace, CriteriaRange:=GroupCriteria
End with
End Select
End Sub

regards
Paul

 
Reply With Quote
 
=?Utf-8?B?VHJldmVyIEI=?=
Guest
Posts: n/a
 
      9th Mar 2007
Yes I did read the section but still did not like it and still no joy.

However Paul Robinson seams to have the answer

Thanks anyway

Regards

Trev



"NickHK" wrote:

> Did you read this section ?
> <Quote>
> a single item (e.g. 'SMITH') underneath one of the fields
> more than one criteria item in a single row - applies an 'AND' rule (e.g.
> 'SMITH' and 'XN41')
> more than one criteria on different rows - applies an 'OR' rule (e.g. 'XN41'
> or '<1500')
> </Quote>
> So you have to create your criteria in a column of
> A
> B
> C
>
> NickHK
>
> "Trever B" <(E-Mail Removed)> wrote in message
> news:07DB491A-7444-40EE-96A1-(E-Mail Removed)...
> > Thanks Nick,
> >
> > Not much help
> >
> > It does not help me how to input multi creteria,
> >
> > Have tried:-
> > 1) = "A" and "B" and "C"
> > 2) = "A" or "B" or "C"
> >
> > Tried recording a macro but still need help on criteria
> >
> > Don't know what else to try.
> >
> > Hope someone else can help.
> >
> > Trev
> >
> >
> >
> > "NickHK" wrote:
> >
> > > Trev,
> > > Maybe this will help:
> > > http://www.meadinkent.co.uk/xlfilter.htm
> > >
> > > Record a macro whilst you do this to generate the code.
> > >
> > > NickHK
> > >
> > > "Trever B" <(E-Mail Removed)> wrote in message
> > > news:3DCB10D1-3D54-485F-A5C5-(E-Mail Removed)...
> > > > Hi,
> > > >
> > > > Thanks in advance
> > > >
> > > > The following code is set for Creteria1 to = "A" how do I make it for

> A, B
> > > > or C
> > > >
> > > > With Worksheets("Panel Details").Range("A1:IV2500")
> > > > .AutoFilter Field:=1, Criteria1:="A"
> > > > .SpecialCells(xlCellTypeVisible).Copy _
> > > > Worksheets("SS A").Cells(1, 1)
> > > > .AutoFilter
> > > > End With
> > > >
> > > >
> > > > Thanks again
> > > >
> > > > Trev
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?VHJldmVyIEI=?=
Guest
Posts: n/a
 
      9th Mar 2007
Thanks Paul

Works a treat

Trev

"(E-Mail Removed)" wrote:

> Hi
> Autofilter only lets you filter on two criteria at most. For 3
> criteria you need advanced filter.
> I'll assume you are selecting your criteria from a multiselect
> listbox. If not, this should give you a start
>
> Private Sub OKButton_Click()
> Dim Grouplistdata As New Collection
> Dim i As Integer, GroupCount As Integer
> Dim Item As Variant
> Dim GroupCriteria As Range
>
> Application.ScreenUpdating = False
> With RegGroups.GroupList
> 'Get the data in the GroupList ListBox
> For i = 0 To .ListCount - 1
> 'for each Group in the list
> If .Selected(i) Then
> Grouplistdata.Add .List(i)
> End If
> Next i
> End With
>
> GroupCount = Grouplistdata.Count
> 'Remove any filter present
> With Worksheets("Panel Details")
> On Error Resume Next 'required if Advanced filter used
> .ShowAllData
> On Error GoTo 0
> .AutoFilterMode = False 'Removes drop down arrows
> End With
> Select Case GroupCount
> 'Check the user hasn't clicked OK on the ViewList userform without
> selecting anything
> Case 0
> Exit Sub 'nothing happens and form is still visible
> 'Use AutoFilter if GroupCount is 1 or 2
> Case 1
> Worksheets("Panel Details").Range("A1:IV2500").AutoFilter
> Field:=1, Criteria1:=CStr(Grouplistdata(1))
> Case 2
> Worksheets("Panel Details").Range("A1:IV2500").AutoFilter
> Field:=1, Criteria1:=CStr(Grouplistdata(1)), Operator:=xlOr,
> Criteria2:=CStr(Grouplistdata(2))
> Case Is > 2
> 'Start by inserting a worksheet and creating a Criteria Range to put
> into AdvancedFilter
> 'addSheet first removes the sheet, so it is always a fresh sheet
> AddSheet "WorkSpaceSheet" 'now the active sheet
> With ActiveWorkbook.Worksheets("WorkSpaceSheet")
> .Visible = False
> .Cells(1, 1).Value = "Group" 'same as heading on worksheet
> for "A", "B", "C",..
> i = 1 'set a counter and put group items below "Group"
> For Each Item In Grouplistdata
> i = i + 1
> .Cells(i, 1).Value = Item
> Next Item
>
> Set GroupCriteria = .Cells(1, 1).CurrentRegion
> End With 'worksheet
> 'Filter the list
> With Worksheets("Panel Details")
> .Activate
> .Range("A1:IV2500").AdvancedFilter
> Action:=xlFilterInPlace, CriteriaRange:=GroupCriteria
> End with
> End Select
> End Sub
>
> regards
> Paul
>
>

 
Reply With Quote
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      9th Mar 2007
Hi
I forgot to insert the AddSheet macro, so it did well to work!

Public Sub AddSheet(TheSheetName As String)
Dim wsNew As Worksheet 'we will insert a fresh worksheet
With ActiveWorkbook
On Error Resume Next
Application.DisplayAlerts = False
.Worksheets(TheSheetName).Delete
On Error GoTo 0
Application.DisplayAlerts = True
'If worksheet is not there the error in deletion is ignored
'Add a new sheet
Set wsNew = .Worksheets.Add(after:=Worksheets("Panel Details"))
'Makes wsNew the active sheet
wsNew.Name = TheSheetName
End With
Set wsNew = Nothing
End Sub

regards
Paul


 
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
if creteria is not found =?Utf-8?B?SWd1c3M=?= Microsoft Excel Discussion 17 12th Nov 2007 03:52 PM
Use Input Box Value as Creteria =?Utf-8?B?TWF4?= Microsoft Access VBA Modules 4 22nd Apr 2007 10:12 AM
creteria using other fields =?Utf-8?B?R2VvcmdlIFdhbHRlcnM=?= Microsoft Access Queries 1 2nd Apr 2006 02:35 PM
creteria macros =?Utf-8?B?c2llcnJhbGlnaHRmb290?= Microsoft Access Queries 13 8th Mar 2006 06:13 AM
Creteria Loi Microsoft Access Queries 1 13th May 2004 08:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:36 AM.