+ Reply to Thread
Results 1 to 3 of 3

Running a macro on a protected worksheet - runtime error 1004

  1. #1
    Registered User
    Join Date
    01-11-2016
    Location
    London, England
    MS-Off Ver
    2010 Standard at work, Professional Plus at home
    Posts
    2

    Running a macro on a protected worksheet - runtime error 1004

    Hi all,

    I was wondering if someone might be able to help please?

    Short version:
    I'm getting a runtime error 1004 on a doc when trying to run a macro on a protected sheet.

    Long version:
    I'm using Excel 2013 (my company hasn't updated me to 2016/365 yet!). I have a series of pivot-tables reading from a master sheet and feeding data into graphs/tables/maps in a dashboard. This dashboard is to go on our website and is for use by the general public.

    In the dashboard I want to be able to flip the values in a series of text boxes on a map between "headcount" and "full-time equivalents (FTE)" (a calculation that factors in part-timers and full timers and extrapolates to a workforce as a whole - in case you're not familiar with this term).

    Because the data from the master datasheet must be pivoted in several different ways and then combined with loads of calculations in order to get the FTE calculation, I need to then feed the original pivoted data into a new table that does all the calcs and then that new summary table is pivoted from. This latter pivot-table controls how the data will appear in the text boxes on the map.

    So the order goes like this:

    1. Master datasheet ->
    2. Pivots (connected to a series of slicers in the doc) ->
    3. Summary table bringing data from multiple pivots in (2) and then performing calcs ->
    4. Another pivot ->
    5. Map values

    Every time a slicer connected to the first set of pivot-tables (2 in the list above) is clicked, it updates those pivots, but not the pivot connected to the new summary table (3 in the list above). The solution to that was to build a button, write REFRESH on it, and assign a macro to it that refreshes the new pivot-table (4 in the list above) each time that refresh button is pressed. It's a bit Rube Goldberg, but it works.

    However, seeing as this is a dashboard for the general public I want to password-protect it. But if I protect the sheet I get a runtime Error 1004 every time the refresh button is clicked, saying that I can't run macros on a protected sheet.

    I hope that's clear enough?! Please can someone advise how to get around this?

    BTW - I'm fine in most aspects of Excel, but I'm not a coder so I might ask stupid questions about any code/etc you suggest!

    Thanks for your help.

    C

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Running a macro on a protected worksheet - runtime error 1004

    Can you not put the unprotect code in the macro before the run then protect again after the run?
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Running a macro on a protected worksheet - runtime error 1004

    You're welcome and thanks for the rep!

+ 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. Runtime error 1004 when running excel macro. Other users do not have same issue with file
    By macronewbie99 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-09-2018, 02:23 PM
  2. [SOLVED] Validation macro causes error 1004 when worksheet is protected
    By Solvax in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2018, 09:50 PM
  3. Macro Not Working in "Protected View". Runtime Error 1004
    By rxharp419 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2018, 04:12 AM
  4. Help with Macro : runtime error 1004 paste method of worksheet class failed
    By aka189 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-26-2012, 05:32 PM
  5. Protected sheets w/macros giving runtime error 1004
    By cedarhill in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-03-2009, 07:59 AM
  6. [SOLVED] [SOLVED] run time error 1004 on protected worksheet when I try to run macro
    By dtg_denver in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-12-2005, 09:05 PM

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