+ Reply to Thread
Results 1 to 3 of 3

How to change Pivot table with Combobox selection

Hybrid View

  1. #1
    Registered User
    Join Date
    10-27-2006
    Posts
    60

    How to change Pivot table with Combobox selection

    Hi all,

    I am trying to find a way to change a page field on a pivot table with the selection made in a combo box. I am trying to change the "P.5256" to whatever the user selects in the combo box.

    Any Ideas on how to do this?
     
    Sheets("Selected Points Charts").Select
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveChart.PivotLayout.PivotTable.PivotFields("Point ID").CurrentPage = _
            "P.5256"
        ActiveChart.SeriesCollection(1).Select
        ActiveChart.SeriesCollection(1).Trendlines.Add(Type:=xlLinear, Forward:=0, _
            Backward:=0, DisplayEquation:=False, DisplayRSquared:=False).Select
        Windows("Points Statistics 2.xls").SmallScroll Down:=21
        ActiveWindow.Visible = False
        Windows("Points Statistics 2.xls").Activate
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.PivotLayout.PivotTable.PivotFields("Point ID").CurrentPage = _
            "P.5256"
    Last edited by VBA Noob; 12-17-2006 at 11:30 AM.

  2. #2
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    Below assumes that you have a ComboBox named "ComboBox1" on a Sheet with CODENAME "Sheet1". (Note: the CodeName of a worksheet is the name on the left in the VB Editor Project Explorer view ... the name in parenthesis is the Name, which is what shows on the Tab in Excel view).

    Dim ch As Chart, pt As PivotTable
    Dim pf As PivotField
    Dim cb As ComboBox
    
        Set ch = ActiveSheet.ChartObjects("Chart 2").Chart
        Set pt = ch.PivotLayout.PivotTable
        Set pf = pt.PivotFields("Point ID")
        Set cb = Sheet1.ComboBox1
    
        pf.CurrentPage = cb.Value
    Last edited by MSP77079; 12-17-2006 at 01:08 PM.

  3. #3
    Registered User
    Join Date
    10-27-2006
    Posts
    60
    Thank you so much MSP77079, worked a treat.

    Neil

    Merry Christmas to you all

+ 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