+ Reply to Thread
Results 1 to 25 of 25

Protect Conditional Formatting on Unlocked Cells

  1. #1
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Protect Conditional Formatting on Unlocked Cells

    Hi,

    I have a protected worksheet. Some cells in the sheet are "Unlocked" because I want to change values. I also have conditonal formatting attached to these Unlocked cells. If someone Copy & Paste within the range of unlocked cells, my conditional formatting is destroyed. Is there a way to protect conditional formatting on unlocked cells within a protected sheet?
    1. Reply to thread and inform if suggestion was helpful or not
    2. Click on the star (=Add Reputation) if you think someone helped you
    3. Mark [SOLVED] to this thread if solution was found. (On Menu "Thread Tools" > "Mark this thread as solved")

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Protect Conditional Formatting on Unlocked Cells

    Are you happy to use VBA?
    - it is the only way
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Protect Conditional Formatting on Unlocked Cells

    Thanks,
    I use VBA quite much. I was hoping for a built in solution. I believe many users have the same issue.

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Protect Conditional Formatting on Unlocked Cells

    It is the same problem with DataValidation - copy/paste destroys that too
    Microsoft should have addressed this years ago

    There is more than one way to attack your problem - do you want to prevent users copy/pasting if cell has CF or do you want users to be able to do that?

  5. #5
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Protect Conditional Formatting on Unlocked Cells

    My objective is that users only can Paste Values in unlocked cells on a protected sheet. Nothing else.

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Protect Conditional Formatting on Unlocked Cells

    Test in attached workbook - is it too restrictive?
    - cut,copy & paste all disabled

    The only way to copy and paste values:
    SELECT a range \ {CTRL} k \ select pasteTo cell with mouse \ click "OK"

    I have not tested it to any extent
    - I suspect it needs refining to deal with user "finger trouble" when used in conjunction with replacement macro

    But do you think this is something you can use?


    Replacement macro
    Please Login or Register  to view this content.

    Credit for this code due to Ken Puls
    Found here http://www.vbaexpress.com/kb/getarticle.php?kb_id=373
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Protect Conditional Formatting on Unlocked Cells

    Thanks for your reply,
    I'll look into this material. I believe I can find something useful. At least I will leatn some new VBA code.

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Protect Conditional Formatting on Unlocked Cells

    I will post another option on Sunday

    How many different conditional formatting conditions are there in the "unlocked" cells?

  9. #9
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Protect Conditional Formatting on Unlocked Cells

    Hi,

    (This request should probably be moved to VBA discussion group now. My first intention was to find a bulit in solution in Excel application)

    I am very close finding a solution that suits me. Following code prevents a UserMode = "User" to use Paste or Autofill. I wanted to allow only "Paste Special Values". However:
    Please Login or Register  to view this content.
    returned "Paste Special" for all type of Paste Special Operaration. I wanted to prevent "Paste Special Formats" also. Now I can't differ between paste Values or Formats.
    Please Login or Register  to view this content.
    This is better than nothing.
    Attached Files Attached Files

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,968

    Re: Protect Conditional Formatting on Unlocked Cells

    Thread moved to VBA section.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  11. #11
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Protect Conditional Formatting on Unlocked Cells

    How about this
    - the values are pasted for ordinary pasting

    Please Login or Register  to view this content.
    It may be possible to paste Fill values only too. The basic code is
    Please Login or Register  to view this content.
    - I will investigate further....
    Last edited by kev_; 03-24-2018 at 07:47 AM.

  12. #12
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Protect Conditional Formatting on Unlocked Cells

    This seems to work with "Fill"
    - user asked to select the fill range again
    - on error required in case user messes up range selection

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Protect Conditional Formatting on Unlocked Cells

    Kev_,

    This solution is great.

    I modified some for Auto Fill so you don't have to use InputBox. It works for me. Maybe I haven't thought of everything that can occur.

    Please Login or Register  to view this content.

  14. #14
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Protect Conditional Formatting on Unlocked Cells

    If it works then that is better for user

    I would like understand why it gives correct result
    It looks wrong because
    source = selection
    destination = selection
    But if Excel fills correctly why worry?

  15. #15
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Protect Conditional Formatting on Unlocked Cells

    Thanks Kev,

    I judge this request as solved. Nice support from you.

  16. #16
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Protect Conditional Formatting on Unlocked Cells

    I found that AutoFill only worked in direction Down or Right before. Now it works for Left and Up also.

    Please Login or Register  to view this content.

  17. #17
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Protect Conditional Formatting on Unlocked Cells

    See post#16
    Please Login or Register  to view this content.
    gives the correct result ONLY if single cell is used to fill down

    BUT if
    A1 = 2 and A2 = 4

    Normal Fill returms
    A3= 6, A4 = 8 etc

    Above code returns
    A2 = 2, A3 = 2 , A4 = 2

    I will investigate....

  18. #18
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Protect Conditional Formatting on Unlocked Cells

    Following code seems to solve the issue with 2 adjacent cells to be Auto Filled:
    Please Login or Register  to view this content.

  19. #19
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Protect Conditional Formatting on Unlocked Cells

    Or even better:
    Please Login or Register  to view this content.

  20. #20
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Protect Conditional Formatting on Unlocked Cells

    better ?
    yes and no

    yes - FILL works perfectly

    BUT code in post#19, pastes values AND format
    - which takes you back to your original problem "my conditional formatting is destroyed"
    Last edited by kev_; 03-24-2018 at 06:24 PM.

  21. #21
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Protect Conditional Formatting on Unlocked Cells

    I have tried both Paste & Autofill. It works fine for me. I don't paste the format.

  22. #22
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Protect Conditional Formatting on Unlocked Cells

    I was referring to Fill in both
    VALUES = GOOD, FORMAT = NOT GOOD

    Here are BEFORE and AFTER images
    - where font colour is RED before and changed to black by the fill

    Fill-BEFORE.jpg Fill-AFTER.jpg

  23. #23
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Protect Conditional Formatting on Unlocked Cells

    We don't get the same result. On my computer it seems to work. Strange.

    VALUES
    FORMAT

    Capture.PNG
    Attached Files Attached Files

  24. #24
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Protect Conditional Formatting on Unlocked Cells

    I deleted the old file and created a new workbook and pasted only that code in there and it worked correctly
    Good

  25. #25
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Protect Conditional Formatting on Unlocked Cells

    Nice kev_,

    I'll just show the last code if someone else is interested.
    Please Login or Register  to view this content.

+ 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. How to protect the formatting of unlocked cells
    By Baldev Kumar in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-14-2014, 07:24 AM
  2. Replies: 2
    Last Post: 09-11-2014, 07:28 AM
  3. Replies: 2
    Last Post: 05-14-2014, 09:14 AM
  4. Enforce formatting in unlocked cells
    By ddgacic in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-01-2013, 08:57 AM
  5. [SOLVED] How do you protect multiple sheets while only allowing users to select unlocked cells?
    By mrssteelerhall in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-15-2013, 02:05 PM
  6. I want to prevent the copy funtion for a range of unlocked cells in protect w/s
    By excel1z008339 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-19-2011, 01:10 PM
  7. [SOLVED] Protect unlocked cells in a protected worksheet from cut/pasting
    By Jerry NeSmith in forum Excel General
    Replies: 0
    Last Post: 11-29-2005, 05:10 PM

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