Results 1 to 1 of 1

Cross post >> Error on extracting datas from Pivottable with VBA

Threaded View

  1. #1
    Registered User
    Join Date
    03-29-2007
    Posts
    1

    Cross post >> Error on extracting datas from Pivottable with VBA

    Hello !

    I try to extract datas from a pivottable.
    This table is composed by 2 fields: "type plate" and "batch"

    The field "batch" is chosen by the user by inputbox
    The items of the second field "type of plate" by default set visible
    The data field is the sum of the "type of plate"

    I want to extract a table giving the sum of the "type of plate" by batch to make calculation on it.


    Problem: it exists some items from the field "type plate" not displayed in the pivot table.

    In my Macro, I calculate the value corresponding at each pivotItem of the pivotfield "type of plate".
    But when the macro calculates "valeur" with a pivotitems not displayed in the pivottable, i have an error "runtime error 1004 application-defined".


    Dim pt1 As PivotTable
    Dim pf As PivotField
    Dim pi As PivotItem
    Dim pj As PivotItem
    Dim i As Double
    Dim valeur As String
    
    Set pt1 = ActiveSheet.PivotTables("PivotTable1")
    Set pf = pt1.PivotFields("Type plate")
    
            p = 0
            i = 10
    
        For Each pi In pf.VisibleItems
       
            Cells(3, 1).Select
                  
         On Error Goto 1                
    
            valeur = ActiveCell.PivotTable.GetPivotData("Number of plates in", "Type plate", pi.Value)
              
            Cells(i, 2) = valeur
            Cells(i, 1) = pi.Value
            
            i = i + 1
            p = p + 1
            
    solution: 
          Next pi
    I tried to go through this problem using "on error goto solution" but it works only one time.

    Question: How can I the datas only appearing in this particular Pivottable ?
    See attached a Picture of my table

    Thank you to help me

    Eloa
    Attached Images Attached Images

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