+ Reply to Thread
Results 1 to 15 of 15

Automatically Sorting a referenced sheet

  1. #1
    Forum Contributor
    Join Date
    04-28-2004
    Location
    Tokyo
    MS-Off Ver
    Office 2016 pro plus
    Posts
    175

    Automatically Sorting a referenced sheet

    I have a dorm roster on one sheet and the other sheet is an Alpha Roster. I want it to automatically sort alphabetically (column B) . Any time I change the roster, the Alpha Roster sheet doesn't automatically sort, I have to hilight and re-sort it again.

    I updated the file, there are 4 tabs at the bottom. 1st Floor, 2nd Floor, and 3rd Floor. I want to have all the names, room numbers, and phases (ph) in alphabetical order on the Alpha roster tab. And when ever I make changes to one of the Floors, it will automatically update it the Alpha Roster.
    Attached Files Attached Files
    Last edited by skylinekiller; 02-18-2009 at 09:34 AM.

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Automatically Sorting a referenced sheet

    You've only referred to two sheets but your upload is massive, help us to help you by being a bit more specific....

    You can solve your problem by inserting a sort method into the sheet_change event - you'd probably also be best off using a dynamic named range for it too. I can show you if you could post a smaller example

    CC

  3. #3
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Automatically Sorting a referenced sheet

    Hi,

    Put this into any of the modules;
    Please Login or Register  to view this content.
    and put this:
    Please Login or Register  to view this content.
    Into the worksheet code for each of the relevant worksheets. You may want to change the sort priority, should be obvious how to do that.

    HTH
    Last edited by Cheeky Charlie; 02-12-2009 at 02:05 PM.

  4. #4
    Forum Contributor
    Join Date
    04-28-2004
    Location
    Tokyo
    MS-Off Ver
    Office 2016 pro plus
    Posts
    175

    Re: Automatically Sorting a referenced sheet

    Thank you, I will try to figure this out. When you say put this into any of the modules, do you mean I can click on any of the 4 sheets and select the VBA options and paste it in there? Where exactly does the worksheet code go. I'm sorry, but I am a somewhat novice user when it comes to certain aspects of excel. And when you say changethe SORT PRIORITY are you referring to be able to sort it by Name, room, ph, etc... well that would be fantastic if thats true. Thank you for your help.

  5. #5
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Automatically Sorting a referenced sheet

    Hi, two things, this is a better implementation (workbook-level event):
    Please Login or Register  to view this content.
    2nd, I thought you had some understanding of VBA from the contents of the workbook, but never mind...
    This code needs to go in the workbook code:
    get there by pressing Alt+F11
    on the left of the window that pops up there should be a project explorer (looks like folder tree)
    find your workbook (looks like VBAPROJECT (NEW ALL ROOMS...)
    open it with the + if not already open
    open Microsoft Excel Objects folder if not already open
    Double click "ThisWorkbook"
    Paste code into here

    Editing the functionality:
    Sheets which effect a sort:
    A line begins "Case sh.name", put the names of any sheet whose changes you want to force a sort of alpha roster into that list
    Sort priority:
    Three lines begin "Key" (1,2, & 3) change which one is A, B or C to define the sort priority.

    HTH

  6. #6
    Forum Contributor
    Join Date
    04-28-2004
    Location
    Tokyo
    MS-Off Ver
    Office 2016 pro plus
    Posts
    175

    Re: Automatically Sorting a referenced sheet

    Ok, I think I did exactly what you said when it came to the VBA portion, but it's still not sorting it. I did not wuite understand the later hald of the sorting part. I ahve attached the modified copy with the VBA embedded into it like you suggested.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Automatically Sorting a referenced sheet

    You're missing the last line... "end sub"

  8. #8
    Forum Contributor
    Join Date
    04-28-2004
    Location
    Tokyo
    MS-Off Ver
    Office 2016 pro plus
    Posts
    175

    Re: Automatically Sorting a referenced sheet

    Sir, I tried to make the corrections, but I am still coming up with the same results. I ahve attached the altered copy. Please advise.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Automatically Sorting a referenced sheet

    This works for me, check the Alpha roster page, then change something in sheets 1st, 2nd or 3rd then check the Alpha roster page again.

    CC

  10. #10
    Forum Contributor
    Join Date
    04-28-2004
    Location
    Tokyo
    MS-Off Ver
    Office 2016 pro plus
    Posts
    175

    Re: Automatically Sorting a referenced sheet

    No sir, it's still not working. I am using Office 2007 FYU. I added my name SOUZA, and it is not even showing on the Alpha Roster, additionally if you notice the pics, the names are not in Alpha order? Wierd
    Attached Images Attached Images

  11. #11
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Automatically Sorting a referenced sheet

    It does work



    If you want to change the sort priority then do so by swapping "A3", "B3", and "C3" which you can see on lines 5, 8 and 11 of the solution given. You may want the order "B3", "A3", "C3".

    I have no idea what you want.

    CC

  12. #12
    Forum Contributor
    Join Date
    04-28-2004
    Location
    Tokyo
    MS-Off Ver
    Office 2016 pro plus
    Posts
    175

    Re: Automatically Sorting a referenced sheet

    On my Alpha Roster, I want all the names of everyone in the Dorm (1st, 2nd, 3rd) in Alphabetical Order. That's pretty much all I want.

  13. #13
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Automatically Sorting a referenced sheet

    Please Login or Register  to view this content.
    See how I've changed it to B3, A3, C3?
    You didn't qualify your sort order when asked and you didn't explain why it wasn't working - you just said "it's not working". How can I help with feedback like that?!?!?!

    /thread

  14. #14
    Forum Contributor
    Join Date
    04-28-2004
    Location
    Tokyo
    MS-Off Ver
    Office 2016 pro plus
    Posts
    175

    Re: Automatically Sorting a referenced sheet

    Sir, I'm sorry I have made you fustrated with my lack of clarity. You have been a great help, and all your help has helped me clear some things up. Thank you again and I'll be closing this post. You were a great help.

  15. #15
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Automatically Sorting a referenced sheet

    Don't worry - it's hard to explain when you don't know why it doesn't work... that doesn't make it easy to understand either though...

    CC

+ 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