+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: Drop Down Box linked to Pivot

  1. #1
    Registered User
    Join Date
    02-08-2007
    Posts
    17

    Question Drop Down Box linked to Pivot

    Hi

    I have a Drop Down / Combo box and when a value is selected I want it to change/update multiple pivot tables.

    I am trying to get it to change for one pivot table first and I have the following code:

    Sub DropDown1_Change()
    ActiveSheet.PivotTables("PivotTable1").PivotFields("SMS").CurrentPage = [NOT SURE WHAT GOES HERE]
    End Sub

    I have read somewhere that I can't link directly to the values in a combo box, but I can use the cell link? If so, how do I do that?

    Thanks in advance....

  2. #2
    Forum Guru Carim's Avatar
    Join Date
    04-07-2006
    Posts
    3,999
    Hi,

    Take a look at Debra's solution ...
    http://www.contextures.com/xlPivot03.html#ShowItem
    HTH
    Carim


    Top Excel Links

  3. #3
    Registered User
    Join Date
    02-08-2007
    Posts
    17
    Thanks for the prompt response!

    But i am not sure what event will trigger the code?

  4. #4
    Forum Guru Carim's Avatar
    Join Date
    04-07-2006
    Posts
    3,999
    Hi,

    I do not know which Excel version you are using ...
    But a standard solution is ...
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    But since you are using a data validation cell, you need to hide somewhere a cell = datavalidationcell ...
    HTH
    Carim


    Top Excel Links

  5. #5
    Registered User
    Join Date
    02-08-2007
    Posts
    17
    Thanks. I got it to work but it isn't quite what I am after?

    I would like something simpler like this example with images:

    http://www.mcgimpsey.com/excel/lookuppics.html

  6. #6
    Forum Guru Carim's Avatar
    Join Date
    04-07-2006
    Posts
    3,999
    With pictures, one can play with the Visible property ...
    But pivot tables are different animals ...
    Why don't you upload a zipped copy of your workbook, I can probably fix it for you ...
    HTH
    Carim


    Top Excel Links

  7. #7
    Registered User
    Join Date
    02-08-2007
    Posts
    17
    Thanks Carim...I've uploaded it...
    Last edited by anoushka; 02-08-2007 at 11:38 AM.

  8. #8
    Forum Guru Carim's Avatar
    Join Date
    04-07-2006
    Posts
    3,999
    Sorry ... but your file has a strange extension which prevents me from opening it ...
    HTH
    Carim


    Top Excel Links

  9. #9
    Registered User
    Join Date
    02-08-2007
    Posts
    17
    Sorry - am using office 2007 and im still getting used to it.

    Try this?
    Attached Files Attached Files

  10. #10
    Forum Guru Carim's Avatar
    Join Date
    04-07-2006
    Posts
    3,999
    Because of Excel 2007, had to start from scratch ...
    Attached Files Attached Files
    HTH
    Carim


    Top Excel Links

  11. #11
    Registered User
    Join Date
    02-08-2007
    Posts
    17
    Thanks so much carim!

    It worked perfectly at home in excel 2000...but it has an error in excel 2007 :S

    It stops at this line

    myField.CurrentPage = myFieldItem

    and says

    "Unable to get the CurrentPage property of the PivotTable"

    Any ideas?

  12. #12
    Registered User
    Join Date
    02-08-2007
    Posts
    17
    Perhaps this error message helps:

    "object variable or with block variable not set"

  13. #13
    Forum Guru Carim's Avatar
    Join Date
    04-07-2006
    Posts
    3,999
    Glad it partially fixed your problem ...

    Unfortunately I do not know Excel 2007 ...
    Most probably, searching within VBA help ( under pivot table object ) would give the answer, which should the new name of "CurrentPage" under Excel 2007 ...

    Thanks for the feedback
    HTH
    Carim


    Top Excel Links

  14. #14
    Registered User
    Join Date
    02-08-2007
    Posts
    17
    ok ive worked it out and i can get it to work but for some reason as soon as it gets to this line

    myField.CurrentPage = myFieldItem

    executes and then goes back to the start

    Private Sub Worksheet_Change(ByVal Target As Range)

    and totally skips the loop..

    so its ends up in an infinite cycle and i dont know why....

  15. #15
    Registered User
    Join Date
    02-08-2007
    Posts
    17
    oh i know why!

    because when its changing the first pivot table its causing a "worksheet change" which triggers the function to execute all over again...

    any idea on what i should change the trigger to?

+ 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.2.0