ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Name of Pivot Table (https://www.excelbanter.com/excel-programming/419888-name-pivot-table.html)

CH

Name of Pivot Table
 
Hi All,

In VBA script when it is running, is there a way to select any cell on the
pivot table and then obtain the name of the pivot table so that I can
manipulate it ?

Thanks.

Bob Phillips[_3_]

Name of Pivot Table
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Me.PivotTables("PivotTable1").TableRange2) Is
Nothing Then

MsgBox Target.Address & " is part of PivotTable1"
End If
End Sub


--
__________________________________
HTH

Bob

"ch" wrote in message
...
Hi All,

In VBA script when it is running, is there a way to select any cell on the
pivot table and then obtain the name of the pivot table so that I can
manipulate it ?

Thanks.




Debra Dalgleish

Name of Pivot Table
 
To get the name of the pivot table for the active cell:

'========================
Sub GetPTName()
Dim pt As PivotTable

On Error Resume Next
Set pt = ActiveCell.PivotTable

If pt Is Nothing Then
MsgBox "Active cell is not in a pivot table"
Else
MsgBox ActiveCell.PivotTable.Name
End If

Set pt = Nothing
End Sub
'=====================

ch wrote:
Hi All,

In VBA script when it is running, is there a way to select any cell on the
pivot table and then obtain the name of the pivot table so that I can
manipulate it ?

Thanks.



--
Debra Dalgleish
Contextures
www.contextures.com/tiptech.html
Blog: http://blog.contextures.com


CH

Name of Pivot Table
 
Thanks Debra, this works just fine.

"Debra Dalgleish" wrote:

To get the name of the pivot table for the active cell:

'========================
Sub GetPTName()
Dim pt As PivotTable

On Error Resume Next
Set pt = ActiveCell.PivotTable

If pt Is Nothing Then
MsgBox "Active cell is not in a pivot table"
Else
MsgBox ActiveCell.PivotTable.Name
End If

Set pt = Nothing
End Sub
'=====================

ch wrote:
Hi All,

In VBA script when it is running, is there a way to select any cell on the
pivot table and then obtain the name of the pivot table so that I can
manipulate it ?

Thanks.



--
Debra Dalgleish
Contextures
www.contextures.com/tiptech.html
Blog: http://blog.contextures.com




All times are GMT +1. The time now is 12:01 PM.

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