Macro to Add current selection to filter

Analyze_This

Board Regular
Joined
Oct 29, 2008
Messages
122
Hey guys,

I'm accessing a data cube and filtering one field (it has thousands) down to only a few hundred items. There is a cool feature in 2010 to search for items and a checkbox that says "Add current selection to filter"

I tried recording a macro to see what the code for this is, but it's the same as just checking the selections you want. So.....

1) does anyone know if there is code to add a selection to the filter or
2) does anyone know a way to filter a couple hundred items at once?

I tried just creating a very long code string, but VBA said it was too long to execute. Any thoughts?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I've used this with success with a single criteria, so it may work for a range like say A10:A50...

Dim fCol As Long 'column to filter on sheet1
Dim Crit As String 'value to filter by
Dim LR As Long 'last row of visible filtered data
On Error Resume Next

fCol = 1 '1st column filtered is 1, 2nd column is 2, etc
Crit = Range("A10").Value 'uses value in cell Range for the filter
Application.CutCopyMode = False

With Sheets("Sheet1")
.Unprotect
.AutoFilterMode = False
.Range("B1:U1").AutoFilter Field:=fCol, Criteria1:=Crit
 
Upvote 0
I'm accessing a data cube and filtering one field (it has thousands) down to only a few hundred items. There is a cool feature in 2010 to search for items and a checkbox that says "Add current selection to filter"

Do you have a filtered PivotTable with a data cube source?

If so, this thread might get you started toward a macro that could do what you describe.

http://www.mrexcel.com/forum/showthread.php?t=565273
You can jump to post #6 for the code.
 
Upvote 0

Forum statistics

Threads
1,224,508
Messages
6,179,188
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top