Autofilter based on Dynamic Cell Values (Pivot Table)

quixter

New Member
Joined
Nov 1, 2015
Messages
20
Hi all,

I have a pivot table that has adjacent columns that work independently of the pivot table. I linked a drop down that users can select from to to control how the pivot table is filtered.

I want to Autofilter out the rows that are blank after the user selects from the drop down, but it seems like the rows that are currently hidden are based on the user's previous choice via the drop down.

Code:
sumws.Range("K13:M42").AutoFilter Field:=1, Criteria1:="<>0", Visibledropdown:=False

Do I need to declare a variable that will load which rows are blank after my user selects from the drop down, then use the auto filter? If so, what is the best way to go about doing that?

Thanks.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
As opposed to using auto filter, I looked on the internet for a For Loop instead. It seems to work better, but it seems to have a success rate of around 80%.

Code:
Dim totalRange As RangeDim cell As Range


sumws.Rows("13:42").Hidden = False




    For Each cell In ActiveSheet.Range("F13:G42")
       If cell = "" And totalRange Is Nothing Then
            Set totalRange = cell
       ElseIf cell = "" Then
            Set totalRange = Application.Union(totalRange, cell)
       End If
    Next
    
    If Not totalRange Is Nothing Then
        totalRange.EntireRow.Hidden = True
    End If
 
Upvote 0

Forum statistics

Threads
1,216,031
Messages
6,128,422
Members
449,450
Latest member
gunars

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