ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pivot Table Macro Help (https://www.excelbanter.com/excel-programming/337636-pivot-table-macro-help.html)

[email protected]

Pivot Table Macro Help
 
Anyone,

I need to assign a name to one of my pivot table columns (The column
will move as users change the page items and such)

so I need excel to find the column figure out the length and assign it
a name so that I can use the name in other functions (conditional
formatting)

Here is what I thought would work:

Worksheets("PSA_Tool").Names.Add _
Name:="Doug1", RefersTo:= _
Worksheets("PSA_Tool").PivotTables("Main").PivotSe lect "'Lon Prem
Bookings Vs Target'", _
xlDataOnly

I get an error telling me it expects end of statement.

Here are the two statements which do work but do not assign a name like
I wanted to:

Worksheets("PSA_Tool").PivotTables("Main").PivotSe lect "'Lon Prem
Bookings Vs Target'", _
xlDataOnly


Worksheets("PSA_Tool").Names.Add Name:="Doug1",
RefersTo:=ActiveArea (Active area gives me a #NA under names)


Any ideas?

Doug


Debra Dalgleish

Pivot Table Macro Help
 
Instead of Activearea, use Selection


wrote:
Anyone,

I need to assign a name to one of my pivot table columns (The column
will move as users change the page items and such)

so I need excel to find the column figure out the length and assign it
a name so that I can use the name in other functions (conditional
formatting)

Here is what I thought would work:

Worksheets("PSA_Tool").Names.Add _
Name:="Doug1", RefersTo:= _
Worksheets("PSA_Tool").PivotTables("Main").PivotSe lect "'Lon Prem
Bookings Vs Target'", _
xlDataOnly

I get an error telling me it expects end of statement.

Here are the two statements which do work but do not assign a name like
I wanted to:

Worksheets("PSA_Tool").PivotTables("Main").PivotSe lect "'Lon Prem
Bookings Vs Target'", _
xlDataOnly


Worksheets("PSA_Tool").Names.Add Name:="Doug1",
RefersTo:=ActiveArea (Active area gives me a #NA under names)


Any ideas?

Doug



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html


[email protected]

Pivot Table Macro Help
 
Debra,

PERFECT! Thanks so much :)

Doug


Debra Dalgleish

Pivot Table Macro Help
 
You're welcome! Thanks for letting me know that it worked.

wrote:
Debra,

PERFECT! Thanks so much :)

Doug



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



All times are GMT +1. The time now is 01:53 AM.

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