+ Reply to Thread
Results 1 to 7 of 7

How to drag and drop multiple filters at once in a pivot table?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-14-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    104

    How to drag and drop multiple filters at once in a pivot table?

    Hello Excel Forum,
    I have the attachced pivot table.

    I wanted to drag and drop fileds "scrub01 to "scrub32" into the "Report Filter" panel.
    I have manually dragged and dropped one by one.

    Q:
    Of course I can do this, but would like to ask if there are any efficinet way to drag and drop all the fileds "scrub01 to "scrub32" into the "Report Filter" panel at once.

    Thanks for the help.
    Mirisa
    Attached Files Attached Files

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: How to drag and drop multiple filters at once in a pivot table?

    I don't think you can multiselect fields.

    this 1 liner in the immediate window will do it.
    for i=1 to 32:ActiveSheet.PivotTables("PivotTable2").PivotFields("scrub" & format(i,"00")).Orientation = xlPageField:ActiveSheet.PivotTables("PivotTable2").PivotFields("scrub" & format(i,"00")).position=1:next i
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    12-14-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    104

    Re: How to drag and drop multiple filters at once in a pivot table?

    Hello Andy Pope,

    Thank you very much for this (I think) excel macro statement.

    for i=1 to 32:ActiveSheet.PivotTables("PivotTable2").PivotFields("scrub" & format(i,"00")).Orientation = xlPageField:ActiveSheet.PivotTables("PivotTable2").PivotFields("scrub" & format(i,"00")).position=1:next i

    Given my basic knowledge could I ask how to implement this statement in the "Book7.xlsx" file?

    Should I re-type above statement in somewhere in the "Book7.xlsx" file?

    Thanks
    Mirisa

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: How to drag and drop multiple filters at once in a pivot table?

    If you need to do it more that once you could add it to a macro in your workbook.

    I was suggesting you simply copy and paste the line into the immediate window of VBE and execute it.
    With your workbook open use ALT+F11 to open VBE. CTRL+G to open Immediate window. Paste in line and with the cursor on the line press enter to execute the instruction.

  5. #5
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: How to drag and drop multiple filters at once in a pivot table?

    Another approach

    Rearange the data in your file, with this macro.

    After that you will be able to add the subcat. at once.

    See the attached file.

    I did not update the pivot table (make a new pivot table).


    Dim rsht1 As Long, rsht2 As Long, i As Long, Col As Long, wsTest As Worksheet
    
    'check if sheet "ouput" already exist
    
    Const strSheetName As String = "Output"
     
    Set wsTest = Nothing
    On Error Resume Next
    Set wsTest = ActiveWorkbook.Worksheets(strSheetName)
    On Error GoTo 0
     
    If wsTest Is Nothing Then
        Worksheets.Add.Name = strSheetName
    End If
    
       
       With Sheets("Output")
        .UsedRange.ClearContents
        .Range("A1:E1").Value = Array("scrubbed", "date", "category", "Sub", "Value")
    
        End With
        
        
        rsht1 = Sheets("sheet1").Range("A" & Rows.Count).End(xlUp).Row
        rsht2 = Sheets("Output").Range("A" & Rows.Count).End(xlUp).Row
        Col = 4
        
        For i = 2 To rsht1
                Do While Sheets("sheet1").Cells(1, Col).Value <> ""
                rsht2 = rsht2 + 1
               
                Sheets("Output").Range("A" & rsht2).Value = Sheets("sheet1").Range("A" & i).Value
                
                Sheets("Output").Range("B" & rsht2).Value = Sheets("sheet1").Range("B" & i).Value
                
                Sheets("Output").Range("C" & rsht2).Value = Sheets("sheet1").Range("C" & i).Value
                
                Sheets("Output").Range("D" & rsht2).Value = Sheets("sheet1").Cells(1, Col).Value
                
                Sheets("Output").Range("E" & rsht2).Value = Sheets("sheet1").Cells(i, Col).Value
                
                
         
                Col = Col + 1
            Loop
            Col = 4
        
        Next
      With Sheets("Output")
     
     ' .Range("E2:E" & .Rows.Count).SpecialCells(4).EntireRow.Delete
       
       Columns("A:Z").EntireColumn.AutoFit
        End With
    Attached Files Attached Files
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  6. #6
    Forum Contributor
    Join Date
    12-14-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    104

    Re: How to drag and drop multiple filters at once in a pivot table?

    Hi Andy Pope and Oeldere,
    Many thanks to both of you for this expert knowledge.

    Regards
    Mirisa

  7. #7
    Registered User
    Join Date
    09-09-2014
    Location
    South Africa
    MS-Off Ver
    2007
    Posts
    1

    Re: How to drag and drop multiple filters at once in a pivot table?

    Hi All
    I have a book that has several (some linked) spreadsheets... Recently some of the spreadsheets formulas were/have been converted to date format. I have changed them back to general format & saved. When re-opening this
    book some of the cells formats have been converted back to "date" format.... This is getting frustrating. Can someone help me please

    Regards

    Mike

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Pivot Table: Multiple Value filters on one field
    By jamsta1972 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 03-27-2014, 02:20 PM
  2. Replies: 3
    Last Post: 08-22-2012, 03:57 PM
  3. Pivot Table Drop Down List (filters)
    By ndreid in forum Excel General
    Replies: 2
    Last Post: 08-22-2012, 01:52 PM
  4. Pivot table multiple filters
    By visualuk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2012, 09:38 AM
  5. Multiple Pivot Table Filters
    By cucrose in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-22-2010, 10:33 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1