Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

1 total

Create a PivotTable cache and report from ADODB.Recordset

// description of your code here
Create a PivotTable cache and report from ADODB.Recordset

Dim objPivotCache   As Object
Set objPivotCache = ActiveWorkbook.PivotCaches.Add( _
    SourceType:=xlExternal)
Set objPivotCache.Recordset = rsNostro
With objPivotCache
    .CreatePivotTable TableDestination:=Range("A43"), _
        TableName:="Performance"
End With

With ActiveSheet.PivotTables("Performance")
    .SmallGrid = False
    With .PivotFields("C_4")
        .Orientation = xlRowField
        .Position = 1
    End With
    With .PivotFields("C_2")
        .Orientation = xlColumnField
        .Position = 1
    End With
    With .PivotFields("C_7")
        .Orientation = xlDataField
        .Position = 1
    End With
End With
1 total