I need to hide/unhide a column when a pivot table is refreshed.
However the Macro I worte runs by
1) creating a new workbook,
2)creates the Pivot table,
but the code I use (see below) only works when I am in "that" workbook! How can a have a macro run in the "New" workbook when the Pivot tables recalulates?
So in my main workbook, I have....
RegardsMsgBox ("Pivot table has been created and formatted.") End Sub Private Sub Worksheet_Activate() 'This works Columns("C").EntireColumn.Hidden = True End Sub Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable) 'This doesn't work! ShowHideLevel End Sub Sub ShowHideLevel() If Columns("C").EntireColumn.Hidden = False Then Columns("C").EntireColumn.Hidden = True Else Columns("C").EntireColumn.Hidden = False End If End Sub
Ronan
Last edited by DonkeyOte; 01-23-2011 at 08:49 AM. Reason: fixed tag
@Ronan, thank you for adding tags.
I appreciate you had not had a response for some time to your question and as such may pursue your line of enquiry elsewhere, however, please note that where and when you post on other boards you are requested to provide links accordingly.
Please read this to understand why we ask you to do this.
Please also bear the above and all other Forum Rules in mind when posting in future.
Thanks in advance for your continued co-operation.
Re: question see: http://www.cpearson.com/excel/vbe.aspx
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks