Identifying Pivot Table's Field

  • Thread starter Thread starter Juan Sanchez
  • Start date Start date
J

Juan Sanchez

Hi all...

Is there a way (with vba) to find out if the active cell
or active range is part of a Pivot Table, and if so
retreiving the pivot table name?

Regards
Juan Sanchez
 
Dim pt as PivotTable
for each pt in Activesheet.PivotTables
if Not intersect(pt.TableRange2,activeCell) is Nothing then
msgbox activeCell.Address & " is in " & pt.Name
Exit for
End if
Next

Change ActiveCell to selection, but that would only indicate if there is an
overlap. If you want totally contained

if Union(pt.TableRange2,Selection).Address = pt.TableRange2.Address then

' totally contained.
 
Tom thanks for your reply... I appreciate it...

Regards
Juan S
 

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

Back
Top