Error 1004 en tabla dinámica excel macro
Disculpe y de antemano Muchas gracias por la respuesta !
Pues mi problema es que cuando ejecuto la macro que creé para crear una tabla dinámica me aparece el runtime error 1004 "Error definido por la aplicación o el objeto"
Le anexo mi código enseguida
Sub main() Dim datos As Worksheet Dim tabla As Worksheet Dim Cache_Tabla As PivotCache Dim Tabla_Dinamica As PivotTable Dim tabla_range As Range Dim ultima_fila As Long Set tabla = Worksheets("Seguimiento PPTO") For Each Tabla_Dinamica In tabla.PivotTables Tabla_Dinamica.TableRange2.Clear Next Set datos = Worksheets("DATOS") ultima_fila = datos.Cells(Rows.Count, 3).End(xlUp).Row Set tabla_range = datos.Cells(1, 1).Resize(ultima_fila, 7) Sheets("DATOS").Select Set Cache_Tabla = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=tabla_range.Address, Version:=xlPivotTableVersion14) Set Tabla_Dinamica = Cache_Tabla.CreatePivotTable(TableDestination:=Worksheets("Seguimiento PPTO").Range("A7"), TableName:="Seguimiento PPTO", DefaultVersion:=xlPivotTableVersion14) Tabla_Dinamica.AddFields RowFields:=Array("Hotel", "Mes", "Segmento", "Subsegmento", "Homoclave", "A/D"), PageFields:="Clasif." With Tabla_Dinamica.PivotFields("CTOS: Real + Fcst") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("CTOS: Fcst. Meta") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("CTOS: Plan") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("CTOS: Real + Libros") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("CTOS: Real + Libros vs Plan") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("CTOS: Real + Libros vs Plan ( % )") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("CTOS: Real + Libros AA") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("CTOS: Cierre AA") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("INGR: Real + Fcst") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("INGR: Fcst. Meta") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("INGR: Plan") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("INGR: Real + Libros") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("INGR: Real + Libros vs Plan") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("INGR: Real + Libros vs Plan ( % )") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("INGR: Real + Libros AA") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("INGR: Cierre AA") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("%OCC: Real + Fcst") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("%OCC: Fcst. Meta") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("%OCC: Plan") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("%OCC: Real + Libros") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("%OCC: Real + Libros vs Plan (PP)") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("%OCC: Real + Librosvs Plan ( % )") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("%OCC: Real + Libros AA") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("%OCC: Cierre AA") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("TP: Real + Fcst") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("TP: Fcst. Meta") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("TP: Plan") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("TP: Real + Libros") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("TP: Real + Libros vs Plan") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("TP: Real + Libros vs Plan ( % )") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("TP: Real + Libros AA") .Orientation = xlDataField .Function = xlSum .Position = 1 .NumberFormat = "#'###,###.##" End With With Tabla_Dinamica.PivotFields("TP: Cierre...
1 Respuesta
Respuesta de Bruno Yanez
1