+ Reply to Thread
Results 1 to 7 of 7

Apply CF Macro to Locked Worksheet

  1. #1
    Forum Contributor
    Join Date
    07-07-2014
    Location
    Nottingham
    MS-Off Ver
    Office 2016
    Posts
    355

    Apply CF Macro to Locked Worksheet

    I have a Workbook that contains sheets that are all linked from live workbooks. The worksheets are Protected so that users only have a Read-Only view of the live data.

    I have a macro that re-applies the CF, but it errors on the
    "If blnClear Then
    .FormatConditions.Delete"
    section of the code.

    Is there any way of unlocking the worksheet when the Macro is called, and locking it again when it finishes?

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    07-07-2014
    Location
    Nottingham
    MS-Off Ver
    Office 2016
    Posts
    355

    Re: Apply CF Macro to Locked Worksheet

    Amended code to the following, and it appears to have resolved

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Apply CF Macro to Locked Worksheet

    Hi there,

    I can't test this properly without access to your workbook, but you could try the following code:

    Please Login or Register  to view this content.
    The highlighted value may be changed to suit your own requirements.

    Hope this helps.

    Regards,

    Greg M

  4. #4
    Forum Contributor
    Join Date
    07-07-2014
    Location
    Nottingham
    MS-Off Ver
    Office 2016
    Posts
    355

    Re: Apply CF Macro to Locked Worksheet

    Hi Greg

    Thanks for the reply. i will post up my workbook just so you can test (if you're bored)

    Does it matter where the "Sheet3.Unprotect" or ".unprotect" commands go?



    Can I assume that because my code starts "With Sheets("Diary_Events").Range("C4:O999")", and "Diary_Events" is Sheet3, then technically I do not need Sheet3 before my .Protect?
    Attached Files Attached Files

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Apply CF Macro to Locked Worksheet

    Hi again,

    Strictly speaking, the code in the workbook you posted should read as follows:

    Please Login or Register  to view this content.
    However, when you look at this code again six months from now, will you remember that "Sheets("Diary_Events")" and "Sheet3" actually refer to the same worksheet???

    The code I posted originally avoids any such potential confusion.

    As a result of having worked with VBA code for more years than I care to remember, my guiding philosophy when writing code is MINIMISE THINKING TIME AFTERWARDS.

    Regards,

    Greg M

  6. #6
    Forum Contributor
    Join Date
    07-07-2014
    Location
    Nottingham
    MS-Off Ver
    Office 2016
    Posts
    355

    Re: Apply CF Macro to Locked Worksheet

    Hi Greg

    Thank you. That makes perfect sense, and I will bear it in mind with anything I work on in the future.

    Darryl

  7. #7
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Apply CF Macro to Locked Worksheet

    Hi again Darryl,

    Many thanks for your feedback and also for the Reputation increase - much appreciated!

    You're welcome - glad I was able to help.

    Best regards,

    Greg M

+ 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] Macro / VBA Script to delete ROW(s) on locked worksheet
    By mowens74 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-20-2017, 07:08 AM
  2. [SOLVED] Apply worksheet change macro every 3rd column
    By Spritz in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-31-2013, 11:34 AM
  3. [SOLVED] Macro to temporarily unprotect sheet to apply filter to locked cell range, then reprotect?
    By lsargent in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-28-2013, 10:27 AM
  4. Replies: 2
    Last Post: 03-07-2012, 09:42 AM
  5. Locked worksheet based upon date and locked columns when worksheet is not locked
    By ruralbrew in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-09-2011, 05:18 PM
  6. How to apply a same macro on two ranges on worksheet
    By leo73pk in forum Excel General
    Replies: 1
    Last Post: 12-28-2010, 05:20 PM
  7. macro apply to all worksheet
    By tango in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2009, 08:07 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