+ Reply to Thread
Results 1 to 17 of 17

Protection Stops Macro From Running

  1. #1
    Registered User
    Join Date
    01-24-2007
    Posts
    13

    Protection Stops Macro From Running

    Hi All,

    I have a very simple request. I want to make the worksheet protected, however, when I protect the worksheet the macro will not run. Does anyone have any useful tips. Many thanks in anticipation.

    Keith
    Last edited by Keith Burgess; 06-10-2008 at 12:26 PM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,438
    You need to remove and re-apply protection within your code.

    Please Login or Register  to view this content.
    You might want to consider remove the attached file as the content looks as though it may be confidential.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You could possibly use Protect with UserInterface, see an example here

    http://www.excel-it.com/vba_examples.htm
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    01-24-2007
    Posts
    13
    Hi Andy,

    Many thanks for your prompt reply. I have cut and pasted your ammended macro but it doesn't seem to work as before, where each line containing the search criteria was highlighted in yellow. Can you help me further, please?

    Best regards
    Keith

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,438
    Works for me.

    Run the macro and search for time.

    EDIT: Confidential file removed
    Last edited by Andy Pope; 06-11-2008 at 07:55 AM.

  6. #6
    Registered User
    Join Date
    01-24-2007
    Posts
    13
    Hi Andy,

    Sorry it doesn't work for me. When I run the nmacro and search for time it takes me to a line within the macro. Can you advise further, please.

    Kind regards
    Keith

  7. #7
    Forum Contributor
    Join Date
    06-03-2008
    Posts
    387
    Quote Originally Posted by Keith Burgess
    Hi Andy,

    Sorry it doesn't work for me. When I run the nmacro and search for time it takes me to a line within the macro. Can you advise further, please.

    Kind regards
    Keith
    It would help you posted the line in the macro it takes you to.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    It works fine. The code finds any row where a cell contains "time2 and highlights it.

  9. #9
    Registered User
    Join Date
    01-24-2007
    Posts
    13
    Hi Guys,

    Below is the line in the macro it takes me to when I run the macro and ask it to search for time. I am using MS Office Excel 2003?
    Please Login or Register  to view this content.
    Hope this helps.

    Kind regards
    Keith
    Last edited by royUK; 06-11-2008 at 04:00 AM.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Is the sheet you are searching active, i.e. the one open?

  11. #11
    Registered User
    Join Date
    01-24-2007
    Posts
    13
    Hi Roy,

    Many thanks for your reply. Yes! the sheet is active and open in fact it is the only worksheet in the workbook.

    Kind regards
    Keith

  12. #12
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I ran andy's code in his example workbook with no errors.

    Can you attach your workbook?

  13. #13
    Registered User
    Join Date
    01-24-2007
    Posts
    13
    Hi Roy,

    Here is the workbook in its original format.

    Kind regards
    Keith
    Last edited by Keith Burgess; 06-11-2008 at 07:17 AM.

  14. #14
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    The code runs perfectly in your workbook.

  15. #15
    Registered User
    Join Date
    01-24-2007
    Posts
    13
    Hi Roy,

    Attached is a protected worksheet (password to unprotect is password). The macro will not run on a protected sheet. What I am trying to do is share the spreadsheet with colleagues and allow them to search for different criteria, however, I want to protect the worksheet so that my colleagues cannot alter any of the data therein. I hope you can help.

    Kind regards
    Keith
    Last edited by Keith Burgess; 06-11-2008 at 07:21 AM.

  16. #16
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,438
    If your sheet already has a password applied then you need to include that in the code where protection is removed and applied.

    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    01-24-2007
    Posts
    13
    Hi Guys,

    Many thanks for working this out for me it now works like a charm. Special thanks go to Roy and Andy for their patience.

    Best Wishes
    Keith
    Last edited by Keith Burgess; 06-11-2008 at 07:27 AM.

+ 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