+ Reply to Thread
Results 1 to 12 of 12

VBA Code to Zoom Data Validation Drop Down Menu Won't Work in Protected Sheet

  1. #1
    Registered User
    Join Date
    10-25-2017
    Location
    Texas, United States
    MS-Off Ver
    Excel 2016
    Posts
    18

    Question VBA Code to Zoom Data Validation Drop Down Menu Won't Work in Protected Sheet

    Hello forum! I have a challenge that I need help with concerning VBA and sheet protection. I have created Data Validation Drop Down Menus in a Worksheet to allow selection from certain lists stored in another sheet. Initially, the font of the options in the drop down menu list was extremely small. I entered the following VBA formula to auto zoom when these cells were selected and return to normal zoom when any other cell was selected:

    Please Login or Register  to view this content.
    I protected other formula containing cells in the workbook and protected the sheet. Now the VBA isn't able to execute and I once again have extremely small font when I try to select from the drop down menus. Does anyone have a fix for this?

    Thanks for the help!
    Last edited by EFD; 10-25-2017 at 10:18 AM.

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

    Re: VBA Code to Zoom Data Validation Drop Down Menu Won't Work in Protected Sheet

    1. Please Edit your post by adding code tags around your code
    - click Edit Post
    - select code text
    - click on # icon above

    2. Your could try UnProtecting the sheet in the VBA just before zooming and Protecting it again after zooming

    Please Login or Register  to view this content.
    Or
    3. Reduce the font size in your cells (by format) and then zoom the sheet to make cell text look bigger. That should eliminate the problem without changing zoom every dropdown.
    Last edited by kev_; 10-25-2017 at 10:22 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Registered User
    Join Date
    10-25-2017
    Location
    Texas, United States
    MS-Off Ver
    Excel 2016
    Posts
    18

    Re: VBA Code to Zoom Data Validation Drop Down Menu Won't Work in Protected Sheet

    Thanks for the reply kev_. Where would I insert those pieces into the code?

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

    Re: VBA Code to Zoom Data Validation Drop Down Menu Won't Work in Protected Sheet

    Try
    UnProtect immediately below
    If Intersect.....
    Protect immediately above
    Exit Sub

    It would be easier to read your code if you indent things - then can work out what belongs together...like this ...
    Please Login or Register  to view this content.
    I usually include a line at the beginning of most of my selection change event macros
    Please Login or Register  to view this content.
    This can prevent problems if you select a large number of cells
    Last edited by kev_; 10-25-2017 at 10:52 AM.

  5. #5
    Registered User
    Join Date
    10-25-2017
    Location
    Texas, United States
    MS-Off Ver
    Excel 2016
    Posts
    18

    Re: VBA Code to Zoom Data Validation Drop Down Menu Won't Work in Protected Sheet

    It didn't work with that arrangement. (New to the VBA coding...not sure where I should be indenting lol)

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

    Re: VBA Code to Zoom Data Validation Drop Down Menu Won't Work in Protected Sheet

    What does "did not work" mean?

    You did change "YourPassword" to the correct value, I hope

    First - let's check that the sheet is being unprotected
    - leave out the Protect line at the end
    - and try selecting a dropdown
    - now manually check status of protection
    - sheet should be unprotected

  7. #7
    Registered User
    Join Date
    10-25-2017
    Location
    Texas, United States
    MS-Off Ver
    Excel 2016
    Posts
    18

    Re: VBA Code to Zoom Data Validation Drop Down Menu Won't Work in Protected Sheet

    Yes I changed the text to the protection password. By not work, I mean that in "protected mode" the Zoom feature from the VBA was not functioning with the Unprotect/Protect code in those spots.

  8. #8
    Registered User
    Join Date
    10-25-2017
    Location
    Texas, United States
    MS-Off Ver
    Excel 2016
    Posts
    18

    Re: VBA Code to Zoom Data Validation Drop Down Menu Won't Work in Protected Sheet

    Still protected following the steps above after selecting a drop down

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

    Re: VBA Code to Zoom Data Validation Drop Down Menu Won't Work in Protected Sheet

    Try moving Unprotect to the FIRST line of your code
    - I think the protection is preventing the macro from triggering

    If that works then you will need to amend a couple of lines in your macro

    Let me know and I will test a couple of things on your macro when i get home
    Last edited by kev_; 10-25-2017 at 01:11 PM.

  10. #10
    Registered User
    Join Date
    10-25-2017
    Location
    Texas, United States
    MS-Off Ver
    Excel 2016
    Posts
    18

    Re: VBA Code to Zoom Data Validation Drop Down Menu Won't Work in Protected Sheet

    With the Unprotect line directly under the "Sub" line, it simply unprotects the workbook as soon as I save the code.

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

    Re: VBA Code to Zoom Data Validation Drop Down Menu Won't Work in Protected Sheet

    It sounds as though the protection is interfering with the event macro, even after the sheet has been unprotected - which I would not expect.
    I will get back to you after I test it on my PC.

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

    Re: VBA Code to Zoom Data Validation Drop Down Menu Won't Work in Protected Sheet

    This works for me
    - try out in attached workbook
    - sheet is protected (password = "ABCD")
    - cells A1 to A20 contain DV
    - select any of those cells and zoom = 85%
    - select any other cell and zoom = 50%

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kev_; 10-25-2017 at 05:08 PM.

+ 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. Replies: 4
    Last Post: 04-19-2017, 03:51 PM
  2. Replies: 4
    Last Post: 10-28-2015, 12:59 PM
  3. How to run code automatically every time a drop-down validation menu changes
    By elgatnegre in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2014, 04:45 PM
  4. ComboBox/Data Validation won't work when sheet is protected.
    By Butler82Paul in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-12-2013, 11:38 AM
  5. Replies: 6
    Last Post: 07-02-2013, 05:23 AM
  6. Replies: 1
    Last Post: 05-15-2013, 01:55 PM
  7. Replies: 0
    Last Post: 06-28-2012, 01:08 AM

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