+ Reply to Thread
Results 1 to 5 of 5

How to adapt 'sort' code to unprotect/protect worksheet

  1. #1
    Valued Forum Contributor
    Join Date
    06-23-2010
    Location
    North West
    MS-Off Ver
    office 2010
    Posts
    355

    How to adapt 'sort' code to unprotect/protect worksheet

    Hello, The following code (without the unprotect bit) does exactly as it is meant to do, and sorts the rows when then date changes in column H, but not when the sheet is protected.
    I have tried to adapt the code to unprotect and then protect again afterwards but it isn't working. Could someone point me in the right direction and explain what I have or haven't done correctly
    Thanks
    Please Login or Register  to view this content.

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How to adapt 'sort' code to unprotect/protect worksheet

    I see the End If.
    Where is the If ?
    Gary's Student

  3. #3
    Registered User
    Join Date
    02-19-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: How to adapt 'sort' code to unprotect/protect worksheet

    make the activesheet the one you want to work on then

    ActiveSheet.Unprotect password:="yourpassword"

    other code

    ActiveSheet.Protect password:="yourpassword"

    here's a piece of code from my VBA, the screen updating is turned off to stop the screen flashing

    Please Login or Register  to view this content.
    Last edited by arlu1201; 02-19-2013 at 02:55 PM.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: How to adapt 'sort' code to unprotect/protect worksheet

    capt_tony,

    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature below this post.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  5. #5
    Valued Forum Contributor
    Join Date
    06-23-2010
    Location
    North West
    MS-Off Ver
    office 2010
    Posts
    355

    Re: How to adapt 'sort' code to unprotect/protect worksheet

    capt_tony, thank you for your code and advice, and thank you Jakobshavn for the word on the 'end if'
    I have removed the 'end if' and it seems to be working now, unless I've missed the point of your comment.

+ 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