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
- 2911 reads
Recent comments
5 years 41 weeks ago
6 years 27 weeks ago
6 years 39 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 48 weeks ago
7 years 4 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago