+ Reply to Thread
Results 1 to 2 of 2

Thread: hide/unhide a column when a pivot table in a new workbook is refreshed.

  1. #1
    Registered User
    Join Date
    08-30-2010
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    28

    hide/unhide a column when a pivot table in a new workbook is refreshed.

    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....

    MsgBox ("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
    Regards

    Ronan
    Last edited by DonkeyOte; 01-23-2011 at 08:49 AM. Reason: fixed tag

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: hide/unhide a column when a pivot table in a new workbook is refreshed.

    @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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0