Results 1 to 3 of 3

Pivot Table Select criteria from cell contents

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,056

    Pivot Table Select criteria from cell contents

    I'm having trouble with one section of my pivot table selection. In my Userform the user selects, for example, "05FIB". My macro picks up that value, copies it to "Steps" worksheet, B2. I then have formulas in the spreadsheet which convert it to "050" in cell C1, and finally my macro copies the formula and pastes as value.

    Then I switch to a pivot table I don't own, which is in another worksheet, and start manipulating it. Everthing works fine until I call the value in Steps, C1, to use for the selection of one of my pivot dropdowns (this one has selctions like "010", "020", "030", etc.I get an error message "Run Time error 1004: unable to set the Default property of the PivotItem class". When I look this up online the usual answer is that the data doesn't exist. However, I think I've got that covered with my conversion above. So I don't know if the problem is with the way I've got my Macro for the pivot configured, or with the way I'm converting "05FIB" to "050". I'd appreciate any help you can give.

    Private Sub CommandButton2_Click()
      Dim DstWkb As Workbook
      Dim i As Long, j As Long  
      Dim SrcWkb As Workbook
      Dim cell As Range
     
       'With Application
            '.ScreenUpdating = False
            '.EnableEvents = False
       
       
      
      'Initialize the workbook object variables
        Set DstWkb = Workbooks("Staffing Projection Tool.xls")
        Set SrcWkb = Workbooks("PAID_FTES_BR2010.xls")
          
        'This one takes the listbox selection and copies to "Steps" worksheet
          For i = 0 To Me!RegionSelect.ListCount - 1
            If Me!RegionSelect.Selected(i) Then
                j = j + 1
                Debug.Print DstWkb.Name
                With DstWkb.Worksheets("Steps")
                  .Cells(i + 2, "A").Copy .Cells(j, "B").Offset(1, 0)
                End With
            End If
          Next i
        
        With DstWkb.Worksheets("Steps")
        Range("C1") = Range("C1").Value
        End With
             
           SrcWkb.Worksheets("BR2010").Activate
    
        With ActiveSheet.PivotTables("PivotTable1").PivotFields("FY 10-11 MFR STRATEGY")
            .Orientation = xlRowField
            .Position = 1
        End With
        With ActiveSheet.PivotTables("PivotTable1").PivotFields("FY 10-11 MFR STRATEGY")
            .PivotItems("B.1.1").Visible = True
            .PivotItems("B.1.2").Visible = True        
        End With
        
        With ActiveSheet.PivotTables("PivotTable1").PivotFields("FY 10-11 MFR STRATEGY")
            .Orientation = xlPageField
            .Position = 4
        End With
    
        ActiveSheet.PivotTables("PivotTable1").PivotFields("Program Area").CurrentPage _
            = "CPS"
    
        'Here's where it stops
        ActiveSheet.PivotTables("PivotTable1").PivotFields("Department").CurrentPage = _
            DstWkb.Worksheets("Steps").Range("C1")    
        
        With ActiveSheet.PivotTables("PivotTable1").PivotFields("PAY_END_DT")
            .PivotItems("3/31/2010").Visible = True
            .PivotItems("4/30/2010").Visible = True
            .PivotItems("5/31/2010").Visible = True
        End With
        
        End with
    End Sub
    Last edited by jomili; 07-28-2010 at 05:09 PM.

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