ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HELP: Error Occurs With Macro Making a Pivot Field Visible (https://www.excelbanter.com/excel-programming/425708-help-error-occurs-macro-making-pivot-field-visible.html)

Clinton M James

HELP: Error Occurs With Macro Making a Pivot Field Visible
 
Hi All,

In code is the following line:

Sheets("Pivot").PivotTables("PivotTable3").PivotFi elds("AS_AT").PivotItems(lastDay).Visible
= True

Where lastday is a string of the last day of the previous month and is a
valid pivot table field - when recorded the macro actually records the above
line except the car lastday is the actual name.

However, every time this code is run an error occurs - Run Time Error 1004:
Unable to get the PivotItems property of the PivotField class.

Even when reocrding and re-running the recorded macro the same error occurs,
which is bizarre seeming excel provided the code itself.

This is in Excel 2007.

If anybody is able to assist fix or work around this error, it would be
greatly appreciated.

Thank you in advance.

Regards,
Clint



All times are GMT +1. The time now is 09:51 PM.

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