+ Reply to Thread
Results 1 to 10 of 10

Radio buttons do not return correct data from pivot table.

  1. #1
    Registered User
    Join Date
    02-21-2013
    Location
    Waco TExas
    MS-Off Ver
    Excel 2003
    Posts
    29

    Radio buttons do not return correct data from pivot table.

    I have a pivot table containing the following data elements:

    EAST.01.07.01
    NORTH_HPAJ
    SOUTH_HPAJ
    WEST.01.06.1
    WEST.01.06.1.2
    WEST.01.09.1.2

    I have 4 option buttons labeled NORTH, SOUTH, EAST, and WEST. As you can see, WEST is comprised of 3 elements, but all these elements are not useful to the user. Only WEST.01.06.1 should be seen by the user. My VBA code is not written to properly return the data. When I choose any of the option buttons, they all return the excess data from WEST. This is just a very simplified explanation, because in reality there will be dozens of unused elements that I don't want to show up. I've attached the relevant spreadsheet. Also, here is my code. I appreciate any help. Thanks and have a blessed day.


    Private Sub test()

    Set sh = ActiveSheet

    On Error Resume Next
    Application.ScreenUpdating = 0

    With Sheets("DETAILS").PivotTables(1).PivotFields("Element")

    .ClearAllFilters

    .PivotItems("NORTH_HPAJ").Visible = sh.OptionButtons(1).Value = 1
    .PivotItems("SOUTH_HPAJ").Visible = sh.OptionButtons(2).Value = 1
    .PivotItems("WEST.01.06.1").Visible = sh.OptionButtons(4).Value = 1
    .PivotItems("EAST.01.07.01").Visible = sh.OptionButtons(3).Value = 1


    End With

    Application.ScreenUpdating = 1

    End Sub
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Radio buttons do not return correct data from pivot table.

    Why should only that one item be returned for WEST?

    This will return all items based on which option button has been selected.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

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

    Re: Radio buttons do not return correct data from pivot table.

    Please Login or Register  to view this content.
    Although I think you might be better off creating a new field for Areas N/S/E/W and filtering the report by those.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    02-21-2013
    Location
    Waco TExas
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Radio buttons do not return correct data from pivot table.

    Only 1 item should be returned for WEST because the other items are either confidential or old and no longer relevant. These items cannot be removed from the data, however, because they are used in other parts of the report. Showing all items is not an option.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Radio buttons do not return correct data from pivot table.

    What indicates the items that are confidential/old/irrelevant?

  6. #6
    Registered User
    Join Date
    02-21-2013
    Location
    Waco TExas
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Radio buttons do not return correct data from pivot table.

    The text/numbers that come after the WEST/EAST/NORTH/SOUTH. Otherwise nothing indicates it other than just the fact that I know which ones should be seen and which ones shouldn't.

  7. #7
    Registered User
    Join Date
    02-21-2013
    Location
    Waco TExas
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Radio buttons do not return correct data from pivot table.

    Thanks for your quick response. The code you attached is still including the unneeded data. Is there not a way to tell it the ones I want to see and make it show only those?

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Radio buttons do not return correct data from pivot table.

    You'll need to write the code so it excludes the elements you don't want.

    Since there's no criteria for that I can't see any other way then hard-coding what not to display

  9. #9
    Registered User
    Join Date
    02-21-2013
    Location
    Waco TExas
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Radio buttons do not return correct data from pivot table.

    Norie, I could probably make your code work for me; however, it supercrunches my computer when I put it into my real file and it shuts Excel down. Is there a way to fix this?

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

    Re: Radio buttons do not return correct data from pivot table.

    Please Login or Register  to view this content.
    I still think you should add another data field that contain information for those records you want displayed.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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