+ Reply to Thread
Results 1 to 7 of 7

Protect on Deactivate

  1. #1
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302

    Protect on Deactivate

    Hi

    I have code on a sheet that I want to run when I activate any other sheet.

    However it doesn't work - there are no errors - it just doesn't protect the sheet on which the code sits.

    Can someone tell me what is wrong.

    thank You

    Allister

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    05-14-2020
    Location
    Mauritius
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Protect on Deactivate

    Hello,

    question: Why you unprotect and protect it in same procedure?
    I would use the Sheet name instead of ActiveSheet. and the EnableOutlining can be in the same command:
    Please Login or Register  to view this content.
    Greetings

    Tor


  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Protect on Deactivate

    Hi Allister,

    could you please make clear to me if you are seeking a code for Shjeets (like stated in text) or Worlbooks (like code)?

    You could be looking for the command Private Sub Workbook_SheetActivate(ByVal Sh As Object) in ThisWorkbook where you should exclude the sheet the code ahould not run if you are looking for a code to run in one workbook. The procedure you posted would just run once when any other workbook is activeated.

    And I have the same question like Tor about the commands in your code.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302

    Re: Protect on Deactivate

    Hi

    Thank You for your reply.

    I have about 40 sheets - is there another way or do I need to in the code name each sheet

    Thank You

    Allister

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Protect on Deactivate

    Hi Allister,

    for one workbook you may use a Select Case to exclude sheets (code goes into ThisWokbook):

    Please Login or Register  to view this content.
    This might give you an idea how to work on the code.

    Ciao,
    Holger

  6. #6
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302
    Thank you
    I want it to run on the sheet. Each time the user clicks off the sheet to another sheet I want the code on the sheet to run

    Thanks again

    Allister

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,913

    Re: Protect on Deactivate

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ 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 worksheet-deactivate 'save as, cut/copy/paste option
    By azmir in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 10-07-2017, 10:15 PM
  2. Deactivate a private sub
    By Jeckford in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2014, 10:58 PM
  3. Deactivate OLEobjects
    By Sagittariu5 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-29-2014, 09:44 AM
  4. Deactivate textboxes
    By lyilaly in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-01-2006, 07:32 PM
  5. Worksheet Deactivate
    By Graham Haughs in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-29-2005, 01:05 PM
  6. [SOLVED] Deactivate a cell
    By Paul in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-14-2005, 07:06 PM
  7. deactivate macro
    By ciquitraque in forum Excel General
    Replies: 0
    Last Post: 03-10-2005, 10:42 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