+ Reply to Thread
Results 1 to 6 of 6

Develop This VBA To Refresh Multiple Rather Than Single Sheet

  1. #1
    Registered User
    Join Date
    07-17-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    27

    Develop This VBA To Refresh Multiple Rather Than Single Sheet

    Hi,

    The code below enables entire workbook protect/unprotect, however ultimately it refreshes a particular sheet (sheet 8 in this instance) when the relevant data table is edited.

    I have 7 sheets (one is the data table and the other 6 house pivots that work off this data table). What I want to happen is for the code to enable the unprotect, refresh and protect of all the sheets exactly like it does for the current sheet 8 (I am simply new to this an am unsure of how to write the code to make the refresh happen for all sheets).

    Please Login or Register  to view this content.
    I have inserted the following code in the 'ThisWorkbook' section to allow for to sheet protection macro to work:

    Please Login or Register  to view this content.
    Along with the following code in the sheet 8 section to enable the refresh macro to work:

    Please Login or Register  to view this content.
    Thanks for all of your time,

    Luke
    Last edited by luke.walker; 06-27-2014 at 10:32 AM.

  2. #2
    Registered User
    Join Date
    07-17-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: Develop This VBA To Refresh Multiple Rather Than Single Sheet

    Apologies - should be corrected

  3. #3
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Develop This VBA To Refresh Multiple Rather Than Single Sheet

    Hi luke.walker,

    You can use the below code to repeat for each worksheet in workbook.

    Please Login or Register  to view this content.
    Where
    1) SheetName = Name of the sheet you dont want to include for refresh.
    2) In place of Do Something, write your code of Refresh() subroutine.



    Regards,
    Paresh J
    Click on "* Add Reputation" as a way to say thanks

  4. #4
    Registered User
    Join Date
    07-17-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: Develop This VBA To Refresh Multiple Rather Than Single Sheet

    Paresh,

    Thank you for your reply I appreciate it.

    Being new to VBA I wasn't sure how to enter the code, however below is what I came up with based on your suggestions:

    Please Login or Register  to view this content.
    With the worksheet already open - I inputted some data into the data table and it seemed to work (pivots refreshed whilst still maintaining protection). However, after saving and closing the workbook, I reopened, clicked on a sheet with a pivot table and got a run time error (1004) - That command can not be performed while a protected sheet contains another PivotTable report based on the same source data.

    Clicking on 'Debug' highlights the 'pt.RefreshTable' section of the code.

    Any thoughts?

    Again thanks for your time and help

  5. #5
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Develop This VBA To Refresh Multiple Rather Than Single Sheet

    Hi,

    Check if this helps, I have not tested this.
    But make sure all worksheets has same password.


    Please Login or Register  to view this content.

    Regards,
    Paresh J

  6. #6
    Registered User
    Join Date
    07-17-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: Develop This VBA To Refresh Multiple Rather Than Single Sheet

    Hi,

    Same problems,

    Should the 's' in your code be 'ws'?

    I can send the spreadsheet if that makes it easier?

    Kindest regards,

    Luke

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] copy data from multiple sheet into last row of existed sheet and refresh pivot
    By sarat47 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2014, 06:49 AM
  2. need to develop Excel sheet for Store Inventory Activities
    By shrikantborkar in forum Excel General
    Replies: 2
    Last Post: 02-06-2014, 11:59 AM
  3. [SOLVED] Pull data if there is any from a single column in multiple worksheets into a single sheet
    By bcas77 in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 07-11-2013, 01:22 PM
  4. Replies: 2
    Last Post: 10-14-2012, 11:06 AM

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