+ Reply to Thread
Results 1 to 25 of 25

RANDOM Sort based on criteria

  1. #1
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    RANDOM Sort based on criteria

    I am in dire need of what I should do to do a sort based on the presence or absence of data. Here's what I am trying to do: I am creating a spreadsheet to randomly assign a list of golfers to foursomes. The list will change from day to day with the number of players ranging from 4 players to 50 players on any given day. I have the spreadsheet pretty much finished except I can't establish a button to do the sort routine. I have the names in column B, no certain number of names each day, beginning in B8, and the RAND() in column C beginning in C8 through C50. I need to know the last filled cell in column B and have the random sort start in the adjacent cell in column C and include column B cells 8 through the last cell with a name in it. It will be the same cell number for both B and C. I would like a button to click that would do this, I hope you understand all this, The way I do it now is to enter the names in column B, highlight the numbers in column C from C8 through the number adjacent to the last name entered. I click on the ascending sort button and it tells me it has detected data in an adjacent field and asks if I want to include it in the sort and I check the box to include it.
    Last edited by Technot; 06-30-2011 at 10:55 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: RANDOM Sort based on criteria

    Hi Technot and welcome to the forum,

    The best way to help us help you is to attach a sample (or your current) workbook. That way we can see where the names are and where they would go after a random sorting of them.

    To attach a sample file, click on the "Go Advanced" below the message area and then on the Paper Clip Icon above the Advanced Message Area. This will open a window that will allow you to point to the file to be attache/uploaded so we can examine it and do some real help.

    I think you are are the right track with putting Rand() next to the names and the sorting by this random number. This is how I do random sorts also. The problem is understanding the rest of the puzzle. Do you know how to code? Are you only using formulas? Do you have links between your names and the scorecard or scoresheet so moving the names around is bad. Too many questions without a sample to see how you have designed your stuff.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Thumbs down Re: RANDOM Sort based on criteria

    For those of you who read my posting I thank you. I have been asked to attach a copy of the Excel Workbook that I have been working on. I believe I told you that my Excel is a 2003 version, never used it very much so I didn't update it. I hope I can read any files that you may send me.

    I believe when you see my spreadsheet it will be more clearer as to mwhat I am trying to do that was my explanation. I guess the important things to remember is that the players list will change every day based on who signs up to play the day before and, as previously stated, the number of players could be from 6 or 8 players to as many as 50.
    The button to do what I need the spreadsheet to do is in B1, and is titled "CLICK TO ASSIGN FOURSOMES"

    Thanks again to all who have looked at this.
    Attached Files Attached Files
    Last edited by Technot; 07-01-2011 at 08:15 PM.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: RANDOM Sort based on criteria

    Hi Technot,

    Find the attached that has VBA code behind a Module. Click the Button in Column B and it will randomly sort all and any names in Columm B.
    Attached Files Attached Files

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: RANDOM Sort based on criteria

    Hi Technot,

    I helped a guy in Houston with his weekend matches last year. I'm attaching his spreadsheet with the names changed to protect the players.

    We had a method where all possible players were listed on a players info sheet and he simply double clicked in column A to put an X (the player was playing) or double click on an X and it cleared him. This kept him from trying to spell there names each week. Then on the next sheet we clicked on Get the players and them on make a random draw. Scorecards were printed from this .. etc.

    He had a very elaborate system - that may give you some ideas. I've created about 7 of these "systems" now and wouldn't use his, but the double clicking the players names was very cute.

    Find it attached.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: RANDOM Sort based on criteria

    I'm having trouble getting the macro to run. It says "Can't execute code in break mode". The screen showing has [break] after the title at the top. I can't get anything on the page to move. The screen is frozen. This is happening when I click the button.

    I thought about putting the entire roster in the sheet but decided against that because the proshop generates a sheet each day with those who have registered and I wanted to keep the listing as small as possible. I will look at the one you did for the guy in Houston, once I can get mine working. Can't get it to run the macro, I believe I have enabled everything. I don't understand the break code statement.

    When I click on the button it gives me a screen that shows some coding that has option explicit at the top. It also gives an error message htat says Compile Error: Variable not defined. In the coding X1sortonvalues is highlighted. I assume the error message is speaking to this coding.
    Last edited by Technot; 07-01-2011 at 10:51 PM.

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: RANDOM Sort based on criteria

    Hi,
    Normally a Break Mode is when you have looked at the code and clicked in the left margin. This will highlight a line of code and the code will run down to this point and stop or break.

    Here comes the file again. I just ran it and I'm pretty sure there is not a break in the code.

    or http://support.microsoft.com/kb/177828
    Attached Files Attached Files
    Last edited by MarvinP; 07-01-2011 at 10:49 PM.

  8. #8
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: RANDOM Sort based on criteria

    I had to shut down ande lost my link.

    It still tells me there is a compilation error.

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: RANDOM Sort based on criteria

    Here is the code I put in a module.
    Please Login or Register  to view this content.
    What version of Excel 2003 do you have? Can you run macros? Is it the Student version? Do you have your VBA security set so it will allow running of macros? Can you look at the macro code? Is this Excel workbook the only one running when you get the error message? Can you run the macro without pushing the Button?

  10. #10
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: RANDOM Sort based on criteria

    Now I'm getting FILE IN USE - Locked for editing. Open READ ONLY or click NOTIFY

    I really appreciate all you are doing, thanks for you help. I don't know how to code a macro or do much of anything other than put numbers in and run analyses.

  11. #11
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: RANDOM Sort based on criteria

    It is not a student version, it came loaded on the computer. I don't know if I have ever run anything that had a macro. I'm sure I have run something with one.

    Still getting message that says it can't execute code in break mode and it refers to a compilation error on line SortOn:

  12. #12
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: RANDOM Sort based on criteria

    Try this one,

    I took the SortOn out!!
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: RANDOM Sort based on criteria

    Just tried to run the macro from the Tools menu and it would not run, It gives me the Can't Execute Code in Break Mode

  14. #14
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: RANDOM Sort based on criteria

    Got Run Time Error '438' Object doesn't support the property or method. It had buttons END and DEBUG. I clicked DEBUG and it gave me another option explicit screen highlighting
    Active workbookworkbooks sort.sortfieldsclear

  15. #15
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: RANDOM Sort based on criteria

    Also when I try to open the program for the guy in Houston it gives me my Heritage file.

  16. #16
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: RANDOM Sort based on criteria

    http://support.microsoft.com/kb/177828
    http://support.microsoft.com/kb/213672 ??


    Keep trying different stuff. Make sure you are not half way entering data in a cell and then press the button.
    Can you see your Visual Basic Editor and read the code I've written?

  17. #17
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: RANDOM Sort based on criteria

    Hi Technot -
    Tell me you are using Microsoft Excel and Not Micorosft Access. What program are you using?
    I just noticed you posted this question on the Access Forum.

  18. #18
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: RANDOM Sort based on criteria

    It's from Microsoft Office. It was suppose to be on Programming program.

    Looks like we are at a dead end. I have spent a entire week trying to figure out this mess. I appreciate your help, As I said befor all I know how to do is put numbers in a spreadsheet. I retired as an accountant and budget executive and never really had hands on.

    Thanks again,

  19. #19
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: RANDOM Sort based on criteria

    I can read the code you wrote.

  20. #20
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: RANDOM Sort based on criteria

    I can't access either version you sent, Did you do something to delete it?

  21. #21
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: RANDOM Sort based on criteria

    Hi,

    I think it must be your version of Excel or a setting you have. Do you have someone with Excel 2007 or better and a net connection that can download my attachment and run it. I've run out of ideas on how your version won't work with my code. I hope you are running Excel and not Access ... I'm clueless on this one. I wish I could sit down at your computer and figure it out.

  22. #22
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: RANDOM Sort based on criteria

    I will look at it on my wife's laptop. She has a newer version. I have a friend who has "cleaned" out my computer several times. I am going to call him and see if he can give me some time.

  23. #23
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: RANDOM Sort based on criteria

    I tried my wife's computer and had the same results.

  24. #24
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: RANDOM Sort based on criteria

    DARN!! Now off to your friend with a newer version of Excel?

  25. #25
    Registered User
    Join Date
    06-30-2011
    Location
    Wake Forest, NC
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: RANDOM Sort based on criteria

    I have been looking on the internet for a vendor that has an online update from 2003 to either 2007or 2010. I understand the 2003 version is quite cheap now with the release of the 2010 version. My wife's version was 2003 also. Hopefully thats all I need to do but as you said there is probably a setting that is not quite right.

+ 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