zoom macro in protected mode

  • Hello, I have a worksheet with several data validation cells. I also have a macro to zoom into each DV cell when selected, to 140%, then back to 100% when any other cell other than a DV cell is selected. The code works great except in protected mode. I have tried using the standard "Protect" and "Unprotect" vba codes, and protect userinterface codes . The zoom macro ( in protected mode) zooms into the 140% but then stops after that. It will not zoom back out to 100%. Once it stops, the code will not work after that. Here is the zoom code I am using.


  • Re: zoom macro in protected mode


    Welcome to the forum!
    This seems to work on my machine. Was it not on yours?

    Best Regards,
    Luke M
    =======
    "A little knowledge is a dangerous thing."

  • Re: zoom macro in protected mode


    Quote from Luke M;716795

    Welcome to the forum!
    This seems to work on my machine. Was it not on yours?



    This is just the code I am using. Yes it works fine. My problem isnt that this code is not working, it is that it doesnt work when I protect my worksheet.

  • Re: zoom macro in protected mode


    Quote from Luke M;716795

    Welcome to the forum!
    This seems to work on my machine. Was it not on yours?


    I had a short but sweet code for zooming. This one works perfectly, the way I want it to except for when I protect the worksheet. This code was my original code that I used when starting to find a solution to the small print of a DV list. I would prefer to use this one if I could, only in protected mode, it doesnt work.

    Code
    1. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    2. If Target.Cells.Count > 1 Then Exit Sub
    3. If Intersect(Target, Range("A3,B3,C3,A5,B5,C5,D5")) Is Nothing Then
    4. ActiveWindow.Zoom = 100
    5. Else
    6. ActiveWindow.Zoom = 140
    7. End If
    8. End Sub
  • Re: zoom macro in protected mode


    Your small code works with both the worksheet and workbook fully protected...perhaps we are talking about different things? When you say "protected mode", are you talking about having the sheet protected? If so, what all do you have checked as an option in the protection? Zoom is a Application object, and shouldn't be affected by worksheet protection at all. :(

    Best Regards,
    Luke M
    =======
    "A little knowledge is a dangerous thing."

  • Re: zoom macro in protected mode


    Thank you Luke. Answers why it wasnt unzooming for me. Wish there was a way to protect all cells except for DV cells, but have it unzoom if any other cell other than DV cells were clicked, even if locked.

  • Re: zoom macro in protected mode


    Actually, that's exactly what the difference between a locked and unlocked cell is. When you protect the sheet, let the user have option to select locked cells. They still won't be able to make any changes to them, and will only be able to edit the unlocked cells (which in your case, are the DV ones).

    Best Regards,
    Luke M
    =======
    "A little knowledge is a dangerous thing."

  • Re: zoom macro in protected mode


    Quote from Luke M;716818

    Actually, that's exactly what the difference between a locked and unlocked cell is. When you protect the sheet, let the user have option to select locked cells. They still won't be able to make any changes to them, and will only be able to edit the unlocked cells (which in your case, are the DV ones).


    Thank you luke. Make alot of sense now. lol