USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets

  • I am looking to achieve the following 3 actions on a workbook (see attached) I am designing:

    1) Sort on the data table on the sheets (Range A2:CM87). The range may change if new rows are added or deleted so if can be done dynamically, that would be ideal. I would love to accomplish the sorting by the following method I found from another site
    [INDENT]Method that allows to sort easily by clicking on the header.

    You could assign a macro to hidden rectangles in the header rows. The macro
    would unprotect the sheet, sort by that column and reprotect the sheet.

    Sample code and file found at Debra Dalgleish's site:
    http://www.contextures.com/xlSort02.html
    [/INDENT]I attempted to use this in my file and received errors. It seems pretty straightforward so I'm not sure why I am getting errors but I am a novice at VB. I would like to have all 91 columns to have the sorting capability.

    2) Allow Filtering on the data table

    3) Allow users to Expand/Collapse Groupings on the Sheets

    I have some Workbook_Open code in the file which allows Outlining but doesn't allow Filtering, Sorting, etc. after the workbook is opened up.




    I attached the sample workbook that I am working with. It's password protected but I didn't use a specific password = "". Any help will be greatly appreciated. I looked for hours trying to find answers for all of these and I can't seem to get it all working.

  • Re: $50 USD Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    For reference, the sample code for Excel: Sort Data With Invisible Rectangles

    "Thanks to Dave Peterson, who wrote this technique.
    To make it easier for users to sort Excel data, and to help prevent scrambled data, you can add invisible rectangles at the top of your columns. When a rectangle is clicked, a macro runs.
    In the macro, the whole data range is selected, and the data is sorted by the column in which the rectangle was clicked. The zipped sample workbook can be downloaded here: SortClick.zip
    Create the Invisible Rectangles

    Run the following code once, to create the rectangles at the top of the table. You can change the iCol variable, to match the number of columns in your table.
    To run the code, copy it to a regular code module, then in Excel, choose Tools | Macro | Macros. Select the SetupOneTime macro, and click the Run button..


  • Re: $50 USD Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    Sorry about that. Below is the corrected version. This can be found at http://www.contextures.com/xlSort02.html as well. I found an sample file with this method as well for reference (attached). No, I do not have a solution but thought this example would help to make it easier to solve with it. I tried using the macros in the sample in my file but kept getting errors. Thanks for your help.



    Use Excel VBA to Sort Excel Data

    The following code runs when one of the rectangles is clicked. You can change the TopRow, iCol and strCol variables, to match the layout of your table.

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    According to the Forum Rules



    I don't see any such statements 3 hours after clarification of the problem statement. So I would like to know whether Rob Xaos is working on this. If yes, then why he didn't adhere to the Forum rules. If Rob Xaos is not working on this then I am interested.

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    GoCavs,
    I think, if you want then according to the Forum Rules I can take over the job. If you agree I will get back to you with a solution within 24 hours. Thanks!

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    Rob Xaos ...just wanted to check to see if you had started to work on my request. If so, could you respond back with a time estimate If not, I will have


    parthasarathi proceed with the job.

    Thanks

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    GoCavs, I don't know when Rob Xaos will reply since he is offline for quite some time now and I can't wait for eternity. So if you want me to proceed with the job, 24 hours will be calculated from my next reply. Thank you!

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    parthasarathi, thank you in advance for your assistance. Yes, please proceed with the job. As I would like to have a solution as soon as possible as well. Let me know if you have any ?'s about my request and I will respond ASAP.

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    I have a few questions but before that I want you to confirm that my understanding about the requirements is correct.
    1) You want the workbook to be designed in such a way that when the user clicks on the header of any column of the table then the entire data in that table will get sorted based on sorting of that column. Now the question comes is do you want this for all the columns from A to CM? If not, then for which columns? Also, do you want sorting in Ascending or Descending order?


    2) Similar to above queries, on which column(s) do you want to apply the filter? How do you want the filtering to be activated? I mean how will the macro know what should it filter out? From where it will get this input - userform or some range or pre-defined in the macro?


    I first want to finish these parts before going to Groupings.


    Thanks!

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    From my understanding the worksheets: "EUR Comp" and "GPB Comp" will be initially protected and should be unprotected by the macro and then re-protected after the action of the macro is over. Is this correct?

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    My Responses:

    1) I would like the functionality to work like the attached example (SortClick.xls). When a user clicks on header (Column B for example), the enitre table will be sorted in A-Z (ascending order) based on values in that column. If Column B is then clicked a another time immediately after, it will sort in Z-A (descending order). Otherwise, if Column C is clicked next, it will sort the table in ascending order based on C. I found the Sample code and file found at this site:
    http://www.contextures.com/xlSort02.html, if this helps. I just couldn't get it to work in my file. Yes, I would like all columns (A:CM) to have the sorting option.

    2) I would prefer to have all columns (A:CM). with the ability to filter. I'm not sure if we could use a dynamic range to accomplish this or if we have to pre-define the range for the entire table in the macro, that would be fine. I just want to protect some columns in the table but allow the user the ability to filter on columns when needed. I tried enabling the "Use AutoFilter" option the Protect Worksheet options and it works but when I close and open up the file, my Workbook_Open sub overwrites this and then blocks filtering. My Workbook_Open sub is some code I found that will allow groupings in a protected sheet.

    3) Correct...the "EUR Comp" and "GPB Comp" will be initially protected and should be unprotected by the macro and then re-protected after the action of the macro is over.

    Thank you again and hopefully these responses help.

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    1) I got your point and it is certainly possible.
    2) Play around with "Locked Cell" and I think your problem will be resolved. (To unlock a cell Right-Click on the cell and then uncheck "Locked Cell" in the "Protection" tab of "Format Cell". While protecting the sheet allow the users to select and modify unlocked cells.


    I will proceed with 1). Let me know if my suggestion for 2 worked. If not I will look over it in more detail.


    Thank you!

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    I tried the playing with the locked cells option. The problem I have is that I would prefer to have some columns with formulas protected to prevent any accidents. So, if there is any method I can allow some columns within the table protected and allow filtering, that would be my preference.

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    My apologies to both GoCavs and Parthasarathi,

    I had fully intended to provide a solution and was working on it. However, as Parthasarthi correctly pointed out I did not provide a time frame after my acceptance. Under the circumstances I will thefore step aside and leave Parthasarathi to complete it.

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    Thank you! Look forward to seeing your sample.

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    Here is a the version 1 of the file with code. It almost solves your problem 1 but not completely.


    The thing is automated way of creating those invisible boxes created the boxes in such a way that in some cases there is overlap with the adjacent columns. So while sorting the "click" is not always sorting that column. To show which column was selected when you click I have introduced a message box. (In Excel Options >> Formulas >> Check the box for "R1C1 reference style". Then you can see the column numbers, NOT "A", "B", "C", etc.)


    For the second problem, I have attached another file which shows how locking and unlocking of cells can affect the editing of a protected sheet. In that file, in worksheet "Dummy" you can enter anything or do anything on any cells except those of Column D. I think this is what you wanted.


    Let me know your thoughts on these. I reply to you tomorrow with solution of the grouping issue. Thank you!

  • Re: USD $50.00 Paypal: Allow Sorting, Filtering, Grouping on Protected Sheets


    Addendum: The "invisible" boxes are not so invisible right now since I have put a Blue border for the time being. Another thing, which you can also see, the boxes are added only the worksheet "EUR Comp". Just run the code "SetupOneTime" while the "GPB Comp" worksheet is the activesheet and then the box will be automatically created in the "GPB Comp" sheet.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!