XLA routines: EE_CreatePivotTableFromRange
EE_CreatePivotTableFromRange creates a pivot table from a range
Function EE_CreatePivotTableFromRange(rngPivotSource As range, rngPivotTarget As range) As Boolean Dim wbk As Workbook Dim objPivotCache As PivotCache Dim objPivotTable As PivotTable 'http://excelexperts.com/xla-routines-eeCreatePivotTableFromRange for updates on this function On Error Resume Next Set wbk = rngPivotSource.Parent.Parent Set objPivotCache = wbk.PivotCaches.Create(xlDatabase, rngPivotSource.Address(1, 1, xlA1, True)) Set objPivotTable = objPivotCache.CreatePivotTable(rngPivotTarget, "Pivot" & wbk.PivotCaches.Count + 1, True) On Error GoTo 0: Err.Clear: On Error GoTo -1 EE_CreatePivotTableFromRange = Not (objPivotTable Is Nothing) Set wbk = Nothing Set objPivotCache = Nothing Set objPivotTable = Nothing End Function
»
- Nick's blog
- Login or register to post comments
- 2881 reads
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago