PivotTable selection

S

SC

Hi,

I've created a PivotTable using code and I can't seem to
find a way to actually select it after it's done (hence,
also display the PivotTable Field List) other than
selecting a cell within my PivotTable.

Is there a function somewhere that would select the newly
created PivotTable no matter where it's residing on the
sheet?

Thanks, SC

BTW, here's a sample of my code if it helps:

Dim oPivot As PivotTable

With ActiveWorkbook.PivotCaches.Add
(SourceType:=xlExternal)
.Connection = {...}
'CreatePivotTable parameters order: TableDestination,
TableName, ReadData, DefaultVersion
Set oPivot = .CreatePivotTable("[beh_gui.xls]Data!
R3C2", "BEHPivotTable", , xlPivotTableVersion10)
End With
oPivot.AddDataField oPivot.PivotFields("Value"), "Total
Value", xlSum

What should come next? For the moment, I have this:
oPivot.EnableFieldList = True
ActiveWorkbook.Sheets(2).Activate
ActiveWorkbook.Sheets(2).Range("B3").Select
 
D

Debra Dalgleish

To select the pivotTable, including the page fields:

ActiveSheet.PivotTables("BEHPivotTable").TableRange2.Select

Hi,

I've created a PivotTable using code and I can't seem to
find a way to actually select it after it's done (hence,
also display the PivotTable Field List) other than
selecting a cell within my PivotTable.

Is there a function somewhere that would select the newly
created PivotTable no matter where it's residing on the
sheet?

Thanks, SC

BTW, here's a sample of my code if it helps:

Dim oPivot As PivotTable

With ActiveWorkbook.PivotCaches.Add
(SourceType:=xlExternal)
.Connection = {...}
'CreatePivotTable parameters order: TableDestination,
TableName, ReadData, DefaultVersion
Set oPivot = .CreatePivotTable("[beh_gui.xls]Data!
R3C2", "BEHPivotTable", , xlPivotTableVersion10)
End With
oPivot.AddDataField oPivot.PivotFields("Value"), "Total
Value", xlSum

What should come next? For the moment, I have this:
oPivot.EnableFieldList = True
ActiveWorkbook.Sheets(2).Activate
ActiveWorkbook.Sheets(2).Range("B3").Select
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top