+ Reply to Thread
Results 1 to 3 of 3

Run Macro when workbook is close

  1. #1
    Registered User
    Join Date
    07-24-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    49

    Run Macro when workbook is close

    All,

    I have multiple workbooks with unique names in one of my folder. Each workbook has similar sheets and it contains pivot values.

    I recorded the program from one of the workbook which selects the fields i need.

    Is there a way I can do this for all the workbooks in the folder without opening one by one?

    Basically I want to run this below macro for each and every workbook in that folder.


    Sub Test()
    '

    '
    With ActiveSheet.PivotTables("PivotTable7").PivotFields("OpCo")
    .PivotItems("").Visible = False
    .PivotItems("Bal").Visible = False
    .PivotItems("Bas").Visible = False
    .PivotItems("Beu").Visible = False
    .PivotItems("Bna").Visible = False
    .PivotItems("Bpl").Visible = False
    .PivotItems("(blank)").Visible = False
    End With
    With ActiveSheet.PivotTables("PivotTable7").PivotFields("Material Group")
    .PivotItems("").Visible = False
    .PivotItems("Corn Oil").Visible = False
    .PivotItems("Feedgrains").Visible = False
    .PivotItems("Freight").Visible = False
    .PivotItems("Livestock").Visible = False
    .PivotItems("Ngfi").Visible = False
    .PivotItems("Oils").Visible = False
    .PivotItems("Oilseeds").Visible = False
    .PivotItems("Potash").Visible = False
    .PivotItems("Sbo").Visible = False
    .PivotItems("Sugar").Visible = False
    .PivotItems("Wheat").Visible = False
    .PivotItems("(blank)").Visible = False
    .PivotItems("Uan").Visible = False
    .PivotItems("Sbm").Visible = False
    .PivotItems("Soybeans").Visible = False
    .PivotItems("Unknown").Visible = False
    .PivotItems("Softseeds").Visible = False
    .PivotItems("Rapeseeds").Visible = False
    .PivotItems("Mapdap").Visible = False
    .PivotItems("Soyabeans").Visible = False
    End With
    End Sub
    Last edited by nih; 09-23-2009 at 09:11 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Run Macro when workbook is close

    Please edit your post to add code tags.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    07-24-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    49

    Re: Run Macro when workbook is close

    ok done

    thx

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.6.0 RC 1