ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Identifying Pivot Table's Field (https://www.excelbanter.com/excel-programming/312435-identifying-pivot-tables-field.html)

Juan Sanchez

Identifying Pivot Table's Field
 
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

Tom Ogilvy

Identifying Pivot Table's Field
 
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.

--
Regards,
Tom Ogilvy

"Juan Sanchez" wrote in message
...
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




Juan Sanchez

Identifying Pivot Table's Field
 
Tom thanks for your reply... I appreciate it...

Regards
Juan S


All times are GMT +1. The time now is 02:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com