ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   PivotTable CurrentPage (https://www.excelbanter.com/excel-programming/336713-pivottable-currentpage.html)

Mark Petruszak

PivotTable CurrentPage
 
I am trying to return the displayed page name of a pivottable. The code that
I have been using is as follows:

Function PvtTablePageName(ByVal pvtTable As PivotTable) As String

Dim pgName As String
Dim pt As PivotTable
Set pt = Worksheets("Sheet1").PivotTables(pvtTable)
pgName = pt.PivotFields("Account #").CurrentPage.Name
PvtTablePageName = pgName

End Function

This returns a #VALUE error. Any help would be appreciated.

Regards,
Mark


Tom Ogilvy

PivotTable CurrentPage
 
I assume you are passing in the Pivot Table name as a string.

Function PvtTablePageName(ByVal pvtTable As String) As String
'comment out the next line if this is not used in a worksheet cell
Application.Volatile
Dim pgName As String
Dim pt As PivotTable
Set pt = Worksheets("Sheet1").PivotTables(pvtTable)
pgName = pt.PivotFields("Account #").CurrentPage.Name
PvtTablePageName = pgName

End Function


--
Regards,
Tom Ogilvy

"Mark Petruszak" wrote in message
...
I am trying to return the displayed page name of a pivottable. The code

that
I have been using is as follows:

Function PvtTablePageName(ByVal pvtTable As PivotTable) As String

Dim pgName As String
Dim pt As PivotTable
Set pt = Worksheets("Sheet1").PivotTables(pvtTable)
pgName = pt.PivotFields("Account #").CurrentPage.Name
PvtTablePageName = pgName

End Function

This returns a #VALUE error. Any help would be appreciated.

Regards,
Mark




Mark Petruszak

PivotTable CurrentPage
 
Thank you Tom. Your answer helped me.

Regards,
Mark


"Tom Ogilvy" wrote:

I assume you are passing in the Pivot Table name as a string.

Function PvtTablePageName(ByVal pvtTable As String) As String
'comment out the next line if this is not used in a worksheet cell
Application.Volatile
Dim pgName As String
Dim pt As PivotTable
Set pt = Worksheets("Sheet1").PivotTables(pvtTable)
pgName = pt.PivotFields("Account #").CurrentPage.Name
PvtTablePageName = pgName

End Function


--
Regards,
Tom Ogilvy

"Mark Petruszak" wrote in message
...
I am trying to return the displayed page name of a pivottable. The code

that
I have been using is as follows:

Function PvtTablePageName(ByVal pvtTable As PivotTable) As String

Dim pgName As String
Dim pt As PivotTable
Set pt = Worksheets("Sheet1").PivotTables(pvtTable)
pgName = pt.PivotFields("Account #").CurrentPage.Name
PvtTablePageName = pgName

End Function

This returns a #VALUE error. Any help would be appreciated.

Regards,
Mark






All times are GMT +1. The time now is 11:26 AM.

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