+ Reply to Thread
Results 1 to 5 of 5

Prohibit sorting in a Worksheet

  1. #1
    Registered User
    Join Date
    05-12-2009
    Location
    Udevalla, Sweden
    MS-Off Ver
    Excel 2007
    Posts
    85

    Prohibit sorting in a Worksheet

    Hi.

    This might sound like a weird question, but is there any way to prohibit a user to using the sort function in a particular sheet?
    Filtering for values is okay but sorting must be prohibited so that no rows "change place" in a sense.


    Any ideas?
    Last edited by Carlsbergen; 10-29-2009 at 04:00 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Prohibit sorting in a Worksheet

    Hi,

    The following line of code should disable the Data Sort menu item for the whole workbook, but not just a sheet. You could password protect the sheet from changes but of course this will also prevent filtering.

    Please Login or Register  to view this content.
    You will need to re-instate it before quitting the s/s with .Enabled = True

    (acknowledgement to Ron de Bruin)

    Rgds
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    05-12-2009
    Location
    Udevalla, Sweden
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Prohibit sorting in a Worksheet

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    The following line of code should disable the Data Sort menu item for the whole workbook, but not just a sheet. You could password protect the sheet from changes but of course this will also prevent filtering.

    Please Login or Register  to view this content.
    You will need to re-instate it before quitting the s/s with .Enabled = True

    (acknowledgement to Ron de Bruin)

    Rgds

    Okay.

    Hmm..

    Is it possible to run a macro everytime you select a sheet that turns this thing on and off? That is the only way I can think of that would make this work the way I want.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Prohibit sorting in a Worksheet

    Yes of course.

    There is a Worksheet_Activate, and a Worksheet_DeActivate event in the VBE that you could use. These would automatically grey out the Data Sort option every time the user moved to the sheet and make it available when the sheet is not the active sheet.

    HTH

  5. #5
    Registered User
    Join Date
    05-12-2009
    Location
    Udevalla, Sweden
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Prohibit sorting in a Worksheet

    Quote Originally Posted by Richard Buttrey View Post
    Yes of course.

    There is a Worksheet_Activate, and a Worksheet_DeActivate event in the VBE that you could use. These would automatically grey out the Data Sort option every time the user moved to the sheet and make it available when the sheet is not the active sheet.

    HTH

    Works great!

    Thanks alot for your help

+ 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