+ Reply to Thread
Results 1 to 2 of 2

IF protection then skip sub.

  1. #1
    Registered User
    Join Date
    06-14-2005
    Posts
    22

    IF protection then skip sub.

    i have an excel document, that works fine and produces another file based on the template.

    On open of the original document, i have a macro to go and clear any data in particular cells.

    When creating the new file, in my macro I have set the new workbook to be protected; however when this file is open, it goes and runs the clear function. This gives an error as it can not clear the cells due to the protection.

    I dont want to turn the protection off, so is there anyway I can check for protection, if protection is found, then dont run the clear code,

    Thanks.

  2. #2
    macropod
    Guest

    Re: IF protection then skip sub.

    Hi mdma,

    You could try something like:
    If ActiveSheet.ProtectContents = True Then Exit Sub
    or
    If ActiveSheet.ProtectContents = False Then
    ' the rest of your clearing code goes here
    End If

    Cheers


    "mdma" <[email protected]> wrote in message
    news:[email protected]...
    >
    > i have an excel document, that works fine and produces another file
    > based on the template.
    >
    > On open of the original document, i have a macro to go and clear any
    > data in particular cells.
    >
    > When creating the new file, in my macro I have set the new workbook to
    > be protected; however when this file is open, it goes and runs the
    > clear function. This gives an error as it can not clear the cells
    > due to the protection.
    >
    > I dont want to turn the protection off, so is there anyway I can check
    > for protection, if protection is found, then dont run the clear code,
    >
    > Thanks.
    >
    >
    > --
    > mdma
    > ------------------------------------------------------------------------
    > mdma's Profile:

    http://www.excelforum.com/member.php...o&userid=24284
    > View this thread: http://www.excelforum.com/showthread...hreadid=536786
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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