View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
DataFreakFromUtah DataFreakFromUtah is offline
external usenet poster
 
Posts: 36
Default Select all pivot table areas/ranges on the active sheet problem

Hi!
Thanks for the word! I have pasted the corrected code below. I also have included a
an alternative procedure that does the same thing as well.

Sub PivotTablesSelectAllOnSheet()

'Select all pivot table areas on the active sheet

Dim i As Integer
Dim rng As Range
On Error Resume Next

With ActiveSheet
For i = 1 To .PivotTables.Count
.PivotTables(i).TableRange2.Select
If rng Is Nothing Then
Set rng = ActiveSheet.PivotTables(i).TableRange2
Else
Set rng = Union(rng, ActiveSheet.PivotTables(i).TableRange2)
End If
Next i
End With
rng.Select

End Sub


Sub PivotTableRangesSelectAll()
'Selects the ranges of all pivot tables on active sheet
Dim i As Integer
Dim rng As Range
On Error Resume Next

With ActiveSheet
For i = 1 To .PivotTables.Count
.PivotTables(i).TableRange2.Select
If rng Is Nothing Then
Set rng = Selection
Else
Set rng = Union(rng, Selection)
End If
Next i
End With
rng.Select

End Sub



search criteria:
select all pivot tables select all pivot table areas
select all pivot table ranges return pivot table ranges to array
return pivot table areas to array create array from pivot table areas
create array from pivot table range
select all pivottables select all pivottable areas on active sheet
loop through pivot tables