Error creando tabla pivote macro - ayudda porfavor

Excel 2010 - Error generando tabla pivote con grabadora de macros
Genero la tabla y me da este erro podria alguien por favor
Este es el codigo siempre me genera una nueva tabla
he tratado quitando
TableDestination:=""
sheets.Add
 Cells(3, 1).Select
y siempre tengo el mismo error
Sub Macro1()
'
' Macro1 Macro
'
'
    Range("D17").Select
    Selection.End(xlUp).Select
    Selection.End(xlToLeft).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Sheets.Add
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "Purchase Order Advanced Fin...!R1C1:R407C11", Version:=xlPivotTableVersion14 _
        ).CreatePivotTable TableDestination:="Sheet2!R3C1", TableName:= _
        "PivotTable2", DefaultVersion:=xlPivotTableVersion14
    Sheets("Sheet2").Select
    Cells(3, 1).Select
    ActiveWorkbook.ShowPivotTableFieldList = True
    With ActiveSheet.PivotTables("PivotTable2").PivotFields("Scheduled By")
        .Orientation = xlRowField
        .Position = 1
    End With
    ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
        "PivotTable2").PivotFields("Scheduled By"), "Count of Scheduled By", xlCount
    Sheets("Sheet2").Select
    Sheets("Sheet2").Move After:=Sheets(2)
End Sub

1 respuesta

Respuesta
1
Yo realizo las tablas dinámicas en una hoja la cual bautizo con el nombre de Reportes y el código que uso para realizar esta macro es:
Sub Tabla_Dinamica
sheets("REPORTES").SELECT
CELLS.SELECT ' ESTA ORDEN SELECCIONA TODAS LAS CELDAS DE LA HOJA
SELECTION.CLEAR ' ESTA ORDEN BORRA TODO EL CONTENIDO
Sheets("Hoja_Fuente").select 'ORDEN QUE SELECIONA LA HOJA FUENTE
Set TBL=range("D17").currentregion
TBL.NAME="BASE"
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "BASE", Version:=xlPivotTableVersion14 _
        ).CreatePivotTable TableDestination:="REPORTES!R3C1", TableName:= _
        "PivotTable2", DefaultVersion:=xlPivotTableVersion14
     ActiveWorkbook.ShowPivotTableFieldList = True
    With ActiveSheet.PivotTables("PivotTable2").PivotFields("Scheduled By")
        .Orientation = xlRowField
        .Position = 1
    End With
    ActiveSheet. PivotTables("PivotTable2"). AddDataField ActiveSheet.PivotTables( _
        "PivotTable2"). PivotFields("Scheduled By"), "Count of Scheduled By", xlCount
    End Sub
Observa que la hoja que selecciona la macro originalmente es la hoja donde tienes la lista
Cualquier inquietud escribeme a [email protected]

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas