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
- 2870 reads
Recent comments
5 years 34 weeks ago
6 years 20 weeks ago
6 years 32 weeks ago
6 years 35 weeks ago
6 years 36 weeks ago
6 years 42 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago