PC Review


Reply
Thread Tools Rate Thread

Combine Advanced Filter with a loop?

 
 
Ray
Guest
Posts: n/a
 
      2nd Oct 2009
Hi -

This one's got me in knots ... hoping someone can help ...

On Sheet1 9 (named 'tracker'), columns B-H contain information related
to employee performance (namely, missed time-clock punches). Column B
holds the date of the infraction. Users interact with Sheet1 via one
two userforms -- 'DateEntry' and 'Report'.

The 'Report' userform contains a listbox ('empData') that initializes
with all data from the 'Tracker' worksheet (using a dynamic named
range = 'nrData'). There're also 2 textboxes ("tframe" and "MPno")
that will hold user entered parameters ... now we get to the real
question.

I need a procedure that will take the values of 'tframe' and 'MPno'
and apply them to nrData, returning a list of employees that meet the
2 criteria. For example:
tframe = 30
MPno = 3

The procedure would loop through nrData and return a list of employees
(and their data from nrData) that had 3 or more missed time-clock
punches in the last 30 days.

I have absolutely no idea where to start with this ... I *think* an
Advanced-Filter may be needed, but beyond that, I'm lost .... Help!

TIA,
Ray
 
Reply With Quote
 
 
 
 
Bernie Deitrick
Guest
Posts: n/a
 
      2nd Oct 2009
Ray,

You could use a pivot table to do all that your describe - show all your desired values in one
table, allow the user to choose the specific set of data being viewed at any one time, etc.

HTH,
Bernie
MS Excel MVP


"Ray" <(E-Mail Removed)> wrote in message
news:d8cc1147-de11-4ea9-a8b9-(E-Mail Removed)...
> Hi -
>
> This one's got me in knots ... hoping someone can help ...
>
> On Sheet1 9 (named 'tracker'), columns B-H contain information related
> to employee performance (namely, missed time-clock punches). Column B
> holds the date of the infraction. Users interact with Sheet1 via one
> two userforms -- 'DateEntry' and 'Report'.
>
> The 'Report' userform contains a listbox ('empData') that initializes
> with all data from the 'Tracker' worksheet (using a dynamic named
> range = 'nrData'). There're also 2 textboxes ("tframe" and "MPno")
> that will hold user entered parameters ... now we get to the real
> question.
>
> I need a procedure that will take the values of 'tframe' and 'MPno'
> and apply them to nrData, returning a list of employees that meet the
> 2 criteria. For example:
> tframe = 30
> MPno = 3
>
> The procedure would loop through nrData and return a list of employees
> (and their data from nrData) that had 3 or more missed time-clock
> punches in the last 30 days.
>
> I have absolutely no idea where to start with this ... I *think* an
> Advanced-Filter may be needed, but beyond that, I'm lost .... Help!
>
> TIA,
> Ray



 
Reply With Quote
 
Ray
Guest
Posts: n/a
 
      2nd Oct 2009
Hi Bernie -

Thanks for responding ... you're correct, it can certainly be done
that way. My 'hesitation' is that many (possibly most) of the users
aren't really that comfortable with Excel, so I'm attempting to make
it as un-Excel like as possible. All user-interaction will be through
userforms ...

Wait, could I have the pivot-table be created/updated 'behind the
scenes' (on a hidden worksheet) and then show the results in the
listbox? I assume I'd need a named range for the pivot-table -- how
is that done?

this is interesting ... I'd have numerous applications for this!

thanks again,
ray

 
Reply With Quote
 
Bernie Deitrick
Guest
Posts: n/a
 
      2nd Oct 2009
You can change what a pivot table shows easily in code, but just make sure that you set all the
items visible prior to hiding other items, since at least one item need to be visible or your code
will error out.

For example, witht he value that you want to show in Worksheets("Sheet1").Range("A1")

Sub Macro2()
Dim myItem As PivotItem

For Each myItem In Worksheets("Sheet3").PivotTables("PivotTable2").PivotFields("name").PivotItems
myItem.Visible = True
Next myItem

For Each myItem In Worksheets("Sheet3").PivotTables("PivotTable2").PivotFields("name").PivotItems
If myItem.Name <> Worksheets("Sheet1").Range("A1").Value Then
myItem.Visible = False
End If
Next myItem

End Sub

You can, of course, use appropriate objects for the worksheets, pivot tables, etc.

You can update the pivot table, and then use GETPIVOTDATA formulas to extract the desired values

See this page for how to form the formulas:

http://www.contextures.com/xlPivot06.html


HTH,
Bernie
MS Excel MVP


"Ray" <(E-Mail Removed)> wrote in message
news:2ee2af0c-4550-4e28-a0da-(E-Mail Removed)...
> Hi Bernie -
>
> Thanks for responding ... you're correct, it can certainly be done
> that way. My 'hesitation' is that many (possibly most) of the users
> aren't really that comfortable with Excel, so I'm attempting to make
> it as un-Excel like as possible. All user-interaction will be through
> userforms ...
>
> Wait, could I have the pivot-table be created/updated 'behind the
> scenes' (on a hidden worksheet) and then show the results in the
> listbox? I assume I'd need a named range for the pivot-table -- how
> is that done?
>
> this is interesting ... I'd have numerous applications for this!
>
> thanks again,
> ray
>



 
Reply With Quote
 
Bernie Deitrick
Guest
Posts: n/a
 
      2nd Oct 2009
The other thing that I should mention is that you can quite often just use a SUMPRODUCT formula to
return the value of interest, instead of the pivot table. It is a little easier to setup, if you are
just looking for a few values.

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org> wrote in message
news:e%(E-Mail Removed)...
> You can change what a pivot table shows easily in code, but just make sure that you set all the
> items visible prior to hiding other items, since at least one item need to be visible or your code
> will error out.
>
> For example, witht he value that you want to show in Worksheets("Sheet1").Range("A1")
>
> Sub Macro2()
> Dim myItem As PivotItem
>
> For Each myItem In Worksheets("Sheet3").PivotTables("PivotTable2").PivotFields("name").PivotItems
> myItem.Visible = True
> Next myItem
>
> For Each myItem In Worksheets("Sheet3").PivotTables("PivotTable2").PivotFields("name").PivotItems
> If myItem.Name <> Worksheets("Sheet1").Range("A1").Value Then
> myItem.Visible = False
> End If
> Next myItem
>
> End Sub
>
> You can, of course, use appropriate objects for the worksheets, pivot tables, etc.
>
> You can update the pivot table, and then use GETPIVOTDATA formulas to extract the desired values
>
> See this page for how to form the formulas:
>
> http://www.contextures.com/xlPivot06.html
>
>
> HTH,
> Bernie
> MS Excel MVP
>
>
> "Ray" <(E-Mail Removed)> wrote in message
> news:2ee2af0c-4550-4e28-a0da-(E-Mail Removed)...
>> Hi Bernie -
>>
>> Thanks for responding ... you're correct, it can certainly be done
>> that way. My 'hesitation' is that many (possibly most) of the users
>> aren't really that comfortable with Excel, so I'm attempting to make
>> it as un-Excel like as possible. All user-interaction will be through
>> userforms ...
>>
>> Wait, could I have the pivot-table be created/updated 'behind the
>> scenes' (on a hidden worksheet) and then show the results in the
>> listbox? I assume I'd need a named range for the pivot-table -- how
>> is that done?
>>
>> this is interesting ... I'd have numerous applications for this!
>>
>> thanks again,
>> ray
>>

>
>



 
Reply With Quote
 
Ray
Guest
Posts: n/a
 
      2nd Oct 2009
Thanks Bernie, I'll check it out ....I love Debra's site



 
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
Advanced Find, Advanced tab: Combine criteria with OR paul.domaskis@gmail.com Microsoft Outlook Discussion 2 26th May 2009 06:40 PM
Loop to Filter, Name Sheets. If Blank, Exit Loop ryguy7272 Microsoft Excel Programming 3 5th Feb 2008 03:41 PM
Combine a Group Filter Control and Hyperlink/Server Filter on 1 DA =?Utf-8?B?U011cnBoeVBFUw==?= Microsoft Access 0 13th Oct 2006 02:42 PM
Advanced Filter to combine multiple entries into one totaled entry shill88 Microsoft Excel Misc 1 7th May 2004 09:10 AM
automating data/filter /advanced filter copy Frank Microsoft Excel Worksheet Functions 2 7th Jan 2004 10:31 PM


Features
 

Advertising
 

Newsgroups
 


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