+ Reply to Thread
Results 1 to 19 of 19

Sorting Rows When Selected Fields are Locked/Protected

  1. #1
    Registered User
    Join Date
    04-27-2017
    Location
    Masschusetts
    MS-Off Ver
    2010
    Posts
    73

    Sorting Rows When Selected Fields are Locked/Protected

    Sample_Census_Report.xlsm

    The attached spreadsheet has two protected/locked columns with auto calculations: Age and Length of Stay. (The protection is mandatory.) The user needs to sort entire rows on column B, “Last Name”. Because the “Age” column is locked, users can only select rows up to the “Age” column. The sorting mechanism is applied to the age column but not beyond. How can I have the sorting override the protection without removing the protection? Hope this makes sense. Thanks for your help.
    Saabra

  2. #2
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Although setting privileges when protecting a worksheet of which sorting is one, Excel doesn't allow you to sort a protected sheet.
    Unless you specify the range to be sorted in the "Allow Users to Edit Ranges" window.
    Unprotect the sheet. Then in the Review tab select "Allow Users to Edit Ranges" and select "New".
    Then specify the range to be sorted and click "Protect Sheet"

    And don't forget to allow Sorting when protecting the sheet.
    Last edited by Tsjallie; 04-27-2017 at 04:41 PM.
    Cheers!
    Tsjallie




    --------
    If your problem is solved, pls mark the thread SOLVED (see Thread Tools in the menu above). Thank you!

    If you think design is an expensive waste of time, try doing without ...

  3. #3
    Registered User
    Join Date
    04-27-2017
    Location
    Masschusetts
    MS-Off Ver
    2010
    Posts
    73

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Hi Tsjallie,
    I tried your suggestion, but alas the sorting remains static after the age column. Do you think attaching a sorting button with macro behind it would do the trick? If so, what would the macro look like?
    Thanks again,
    Saabra

  4. #4
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Strange. Should work. I'd like to have a closer look.
    Can you upload an unprotected version of the workbook or send the password in a PM?

  5. #5
    Registered User
    Join Date
    04-27-2017
    Location
    Masschusetts
    MS-Off Ver
    2010
    Posts
    73

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Sure. See attached. Sample_Census_Report.xlsm
    Thanks,
    Saabra

  6. #6
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Hi Saabra,
    here's the workbook with Sort working in protected mode.
    The problem was in the configuration of the data area. Excel takes the dataregion as area to sort assuming no headings or only one row of headings.
    But the headings were distributed over 3 rows. And then there was the data header also confusing Excel.
    I made some edits and it works fine now. The edits are reported on the sheet.

    I would also recommend you convert the data area in a table. When inserting new rows the formulas will then be automatically copied to the new row.

  7. #7
    Registered User
    Join Date
    04-27-2017
    Location
    Masschusetts
    MS-Off Ver
    2010
    Posts
    73

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Again, thank you Jsjallie. I'll need some time to digest your work and get back to you.
    Saabra

  8. #8
    Registered User
    Join Date
    04-27-2017
    Location
    Masschusetts
    MS-Off Ver
    2010
    Posts
    73

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Jsjallie,
    I've learned some new things from you. (It's clear that I need more training.)

    I now understand the difference between relative and absolute cell values and how to assign them. I also get why I needed to consolidate the header section into 1 row and insert a row between the current date row and the header row (hidden). I get how you allowed users the use of a specific range.

    However, I don't understand the purpose of:
    1) Moving value of S55 to S53 and
    2) Moving value of T54,55 to T53.

    Can you explain further?
    Thank you,
    Saabra

  9. #9
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Sorting Rows When Selected Fields are Locked/Protected

    However, I don't understand the purpose of:
    1) Moving value of S55 to S53 and
    2) Moving value of T54,55 to T53.
    I did that to have the headers in one cell, so row 54 and 54 could be removed.
    Sorting (in protected mode) needs a single header row which you can include in the range on which to allow sorting.

    You may however choose to not involve the headers in any sorting.
    In that case you should only specify the data range to allow sorting on.

    Difference is that in the latter case you'll need to select the data range whan sorting. Also you would need to allow for selecting locked cells.

    Finally I think merged cells should be avoided when possible.
    When you merge cells horizontally - say D1:F1 - then the whole merged range is addressed as D1. And if merged vertically - say D1:D5 - the whole range is addressed as D1.
    This may give difficulties or errors in formulas or code.

  10. #10
    Registered User
    Join Date
    04-27-2017
    Location
    Masschusetts
    MS-Off Ver
    2010
    Posts
    73

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Okay, now I understand. I think all your suggestions will solve the problem. I really want to thank you for your assistance. If I run into any problems after I've made all the revisions to the original document, can I still contact you with questions? I'll mark this thread solved!
    Barb

  11. #11
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Glad I could help.
    Of course you can always contact me for any further questions.
    I'll keep the subscription to the thread.

  12. #12
    Registered User
    Join Date
    04-27-2017
    Location
    Masschusetts
    MS-Off Ver
    2010
    Posts
    73

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Tsjallie,
    The sorting mechanism is still not working the way I want it to. I made the changes you recommended, protected the worksheet, and tried a sort on column B for the area B66:V81. The selection tool is only allowing up until column E (Age), as it should be, but the sorting is only being applied to columns B through E and not beyond. Maybe there's one more step I'm missing. Can you take a look? REVISED_Facility_Census.xlsm I left tab 1, the census, unprotected. Tab 2 is the other thread you're helping me with which I haven't gotten to. Thanks ever so much.
    Saabra

  13. #13
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Sorting Rows When Selected Fields are Locked/Protected

    ....but the sorting is only being applied to columns B through E and not beyond.
    I cannot reproduce this. Did you select that area prior to executing the sort?

    But the range you allowed users to edit is not correct. The range should include column A as well as the header row (row 65).
    If you change that it should work (it does at my end).
    AllowUsersToEditRanges.JPG

  14. #14
    Registered User
    Join Date
    04-27-2017
    Location
    Masschusetts
    MS-Off Ver
    2010
    Posts
    73

    Re: Sorting Rows When Selected Fields are Locked/Protected

    I did not know that. I'll give it a try. THANK YOU!
    Saabra

  15. #15
    Registered User
    Join Date
    04-27-2017
    Location
    Masschusetts
    MS-Off Ver
    2010
    Posts
    73

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Tsjallie,
    I've attached the step-by-step views of what happens after the edit range is adjusted, etc. Please advise and thanks. Views of Sorting Steps.docx
    Saabra

  16. #16
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Sorting Rows When Selected Fields are Locked/Protected

    In the 2nd screenshot the area B65:E81 is selected.
    If you executed the sort with this area selected then only that area will be sorted. The columns to the right of that area (F:V) will keep their original order.
    That's why Mr Herbert has "moved to another town" after the sort.
    The fact that Mr Herbert is still 72 is because Age is calculated from the DataOfBirth which is included in the sort.
    Just try the sort with only one cell selected and you will see all the columns being sorted.
    Make sure you have the box "My data has headers" checked.

  17. #17
    Registered User
    Join Date
    04-27-2017
    Location
    Masschusetts
    MS-Off Ver
    2010
    Posts
    73

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Tsjallie,
    Not sure if you saw my last reply but the sorting is still not working the way I want it to. Attached is the step-by-step view of what happens after the edit range is adjusted etc. Please advise and thanks. Views of Sorting Steps.docx
    Saabra

  18. #18
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Hi Saabra,
    I believe I replied to your post (#15) with my post #16

  19. #19
    Registered User
    Join Date
    04-27-2017
    Location
    Masschusetts
    MS-Off Ver
    2010
    Posts
    73

    Re: Sorting Rows When Selected Fields are Locked/Protected

    Tsjallie,
    THANK YOU, THANK YOU, THANK YOU. It works. Now, onto the calendar project.
    Saabra

+ 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. Insert Rows When Columns are Locked and Sheet Protected
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-22-2015, 11:30 AM
  2. Inserting copied rows (some locked cells, some not) in a protected sheet
    By kmartinez0180 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2014, 08:09 PM
  3. Sorting a locked table on a protected sheet with VBA
    By Freddobonanza in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 06-07-2013, 05:17 PM
  4. Sorting and filtering Locked cells on Protected Sheet
    By Dumy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-02-2013, 02:16 PM
  5. [SOLVED] Printing selected area that includes locked cells/protected worksheet
    By kmroy0320 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2012, 03:10 PM
  6. Sorting protected/locked sheet-can it be done?
    By AKL01 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-22-2011, 01:43 PM
  7. selecting range across locked rows in protected mode
    By sunilmulay in forum Excel General
    Replies: 0
    Last Post: 10-20-2008, 10:44 PM

Tags for this Thread

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