Run Time Error 1004 'Unable to get the PivotFields property of the PivotTable class
#1
Hallo zusammen,

ich erhalten ständig o. g. Fehler wenn ich zum Code Teil        Set pf = pt.PivotFields("line_group_name")    komme. Soweit ich weiß tritt der Fehler auf, falls das pivot field line_group_name  nicht existiert, dass tut es aber. Hat jemand eine Idee?

Vielen Dank Vorab!
Alex



Code:
Private Sub CommandButton1_Click()

'--- count loop ends ----------------------
Dim I1_end As Variant
    I1_end = ListBox1.ListCount
    
Dim I2_end As Variant 'count table end tb_customer_selection_table
    I2_end = ws_copy_table.ListObjects("tb_customer_selection").Range.Rows.count + 1
    
    
'--- count loops ----------------------------
Dim I1 As Variant 'count loop listbox
Dim I2 As Variant 'count tb_customer_selection_table


Dim ws_name As String
Dim pt_name As String
Dim line_group_name As String
Dim pt As PivotTable
Dim pf As PivotField
         
I1 = 0

Do Until I1 = I1_end

    If ListBox1.Selected(I1) = True Then
    
   
   
        I2 = 2
        Do Until I2 = I2_end

           ws_name = ws_copy_table.ListObjects("tb_customer_selection").Range.Cells(I2, 1).Value
           pt_name = ws_copy_table.ListObjects("tb_customer_selection").Range.Cells(I2, 2).Value
                           
           Set pt = Sheets(ws_name).PivotTables(pt_name)
           [b][color=#ff3333]Set pf = pt.PivotFields("line_group_name")[/color][/b]
           
           pf.PivotItems(ListBox1.List(I1, 0)).Visible = False
         
            
            I2 = I2 + 1
        Loop
        
    End If
    I1 = I1 + 1
    

Loop

Unload Me
ws_sum.Activate

End Sub
Top
#2
Hi,

anonymisierte Beispielmappe?
Top
#3
(14.06.2019, 15:14)Mase schrieb: Hi,

anonymisierte Beispielmappe?

leider nicht möglich, da zu complex > kann ich dir irgendwelche anderen Informationen geben?
Top
#4
Code:
set pf = pt.pivotfields(line_group_name)
Top


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste