Te anexo la macro
Sub Resumen()
'Por.Dante Amor
Application.ScreenUpdating = False
Set h1 = Sheets("datos")
Set h2 = Sheets("bd")
Set h3 = Sheets("Resumen")
'
h2.Cells.Clear
h3.Cells.Clear
If h1.AutoFilterMode Then h1.AutoFilterMode = False
h1.Cells.Copy h2.Range("A1")
u = h1.Range("A" & Rows.Count).End(xlUp).Row
h1.Range("A1:L" & u).AutoFilter Field:=12, Criteria1:="<>0"
u = h1.Range("A" & Rows.Count).End(xlUp).Row
u2 = h2.Range("A" & Rows.Count).End(xlUp).Row + 1
If u > 1 Then
h1.Range("A2:G" & u).Copy h2.Range("A" & u2)
h1.Range("J2:J" & u).Copy h2.Range("I" & u2)
h1.Range("L2:L" & u).Copy h2.Range("K" & u2)
End If
If h1.AutoFilterMode Then h1.AutoFilterMode = False
'
u2 = h2.Range("A" & Rows.Count).End(xlUp).Row
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"bd!R1C1:R" & u2 & "C12", Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:=h3.Name & "!R1C1", TableName:="Tabla dinámica6", _
DefaultVersion:=xlPivotTableVersion12
h3.Select
Cells(1, 1).Select
With ActiveSheet.PivotTables("Tabla dinámica6").PivotFields("departamento")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("Tabla dinámica6").PivotFields("titular")
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("Tabla dinámica6").PivotFields("Tipo ")
.Orientation = xlRowField
.Position = 3
End With
With ActiveSheet.PivotTables("Tabla dinámica6").PivotFields("Mes")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("Tabla dinámica6").AddDataField ActiveSheet.PivotTables _
("Tabla dinámica6").PivotFields("mes1"), "Suma de mes1", xlSum
With ActiveSheet.PivotTables("Tabla dinámica6")
.InGridDropZones = True
.RowAxisLayout xlTabularRow
End With
Range("B9").Select
ActiveSheet.PivotTables("Tabla dinámica6").PivotFields("titular").Subtotals = _
Array(False, False, False, False, False, False, False, False, False, False, False, False)
Range("A9").Select
ActiveSheet.PivotTables("Tabla dinámica6").PivotFields("departamento"). _
Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _
False, False)
Application.ScreenUpdating = True
End Sub
![](//blob.todoexpertos.com/uploads/md/1f99e16f4238f180990faac05eb2c5f7.jpg)
sal u dos