+ Reply to Thread
Results 1 to 13 of 13

Filling rows that are empty that are not all consecutive in a list with from another list

  1. #1
    Registered User
    Join Date
    02-09-2018
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    6

    Filling rows that are empty that are not all consecutive in a list with from another list

    Any help would be greatly appreciated, I am sure this should be simple but I just can not see how to do it.

    My aim it to pull out the text in some selected cells from a column , randomly mix them up and then put them back in a new order sandwiched in between rows that are not changing position, I create a results table to uncomplicated things. The rows that are to be mixed up are in blocks of 8 rows but may well have a set of 8 rows between which will not have been selected to be sorted. The choice of which groups of 8 requiring sorting will change from time to time by a manual user.

    So far I have coded it to extract a copy of the contents of the row/cells to be randomly sorted (the number of rows will always be a fixed number but with groups of 8 can change). I then use RAND to apply a randomly generated number and copy and paste the results as a value to fix the new order which can then be used to sort the order of the text using the RAND number

    Then I am stuck! I can put the rows into the result list that have not changed order using the indicator (<>"x") I used to extract the rows for sorting. I just can not figure out how to populate the result list with the sorted rows when the result rows are not all consecutive. I have tried using an Array which is fine for the first block of 8 but as soon as the next block of 8 follows rows that have remained unchanged it does not select the next available text row from the sorted list.

    I am happy to have a formula or a Macro. I already do the selecting the rows and performing the random sort in a macro.

    Problem.JPG
    Attached Images Attached Images
    Last edited by Frieden; 02-09-2018 at 09:01 AM.

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Filling rows that are empty that are not all consecutive in a list with from another l

    Hi Frieden, welcome to the forum! This macro assumes Exercises are listed in column B, with Sort marked in column C:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by leelnich; 02-09-2018 at 12:13 PM.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

  3. #3
    Registered User
    Join Date
    02-09-2018
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    6

    Re: Filling rows that are empty that are not all consecutive in a list with from another l

    Wow that is very neat. Have stepped through the macro just to make sure I understand the steps as the coding is a few levels above my skill set. I understand the principle that you apply a number column so the rows first and then put the rows that need to be sorted all together at the top (the added number column allowing them to be put back into the correct place after the RAND sort). It all worked perfectly but when I tried it on a longer list which started with a group that was not to go into the mix (not marked with x) the initial sort resulted with all the non 'x' rows at the top. After that the unmixed rows did not go back into the original position. I hope I can explain this clearly. I do not understand the detail of the coding to see why this is.
    Problem 2.JPG

  4. #4
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Filling rows that are empty that are not all consecutive in a list with from another l

    It almost sounds like the code was interrupted. Were you stepping through at the time?

  5. #5
    Registered User
    Join Date
    02-09-2018
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    6

    Re: Filling rows that are empty that are not all consecutive in a list with from another l

    Running the macro on the original small list worked like a dream. I have just run it again (without stepping through) on the extended list and this is the result. Pics Before and after. The only thing I took out of the macro was the screen updating to watch what it does. Sorry to be a bother.

    Problem Pic Before.JPG Problem Pic 2 After.JPG

  6. #6
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Filling rows that are empty that are not all consecutive in a list with from another l

    OK, I'm guessing the "empty" cells in the Sort column aren't actually empty. Do (or did) they have formulas that return empty strings ("")?
    Regardless, this would fix that:
    Please Login or Register  to view this content.
    Last edited by leelnich; 02-10-2018 at 03:26 AM.

  7. #7
    Registered User
    Join Date
    02-09-2018
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    6

    Re: Filling rows that are empty that are not all consecutive in a list with from another l

    When I ran new macro on the same worksheet it did have the same result when first run (mixing up the rows) , However, you hit the nail on the head with the contents!! I 'cleared Content' in the blank cells (not formulas but would have previously had something in at some point) and it worked just fine. My problem is still that in the actually worksheet there will be formulas to add the x as is part of the process that the selection of which sets of 8 which require sorting can be changed by the user. I entered formula on the test sheet and mix up of the rows still occurs even with the extra line of coding which baffles me.
    Sorry to be dragging this out, but I am definitely learning something very interesting.

  8. #8
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Filling rows that are empty that are not all consecutive in a list with from another l

    Sounds like the sorts and the formulas don't play well together. Can you upload the workbook?
    (Remove any personal or proprietary information.)

    To attach a workbook:
    Click Edit Post (or just start a new reply.)
    Click Go Advanced
    Scroll down to Manage Attachments and click.
    Now click Browse, find your file, then click Upload. Simple!

  9. #9
    Registered User
    Join Date
    02-09-2018
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    6

    Re: Filling rows that are empty that are not all consecutive in a list with from another l

    The full workbook has been created in Excel in German so all the formulas are in German, let me know if that's not a problems for you. In the mean time I have attached the test workbook with a dummy formula in the "x" sort column to try to mimic the original.
    It is currently sorting the 'X' to the bottom of the column rather than the top to then allow for the RAND to work correctly.
    The Macro will need the sheet name to be changed back for English Excel.
    Attached Files Attached Files

  10. #10
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Filling rows that are empty that are not all consecutive in a list with from another l

    OK, clearly the sort order in the "X" column is the issue, so I added a test for it in the randomizing formula:
    [Less than "X"] gets a 0, [equals "X"] gets a random number (0<n<1), and [greater than "X"] gets a 1
    Thus anything NOT EQUAL to "X" retains its position during the randomizing sort.
    Please Login or Register  to view this content.
    Last edited by leelnich; 02-11-2018 at 04:05 AM.

  11. #11
    Registered User
    Join Date
    02-09-2018
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    6

    Re: Filling rows that are empty that are not all consecutive in a list with from another l

    Fantastic! Thank you for your expertise and endurance!

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Filling rows that are empty that are not all consecutive in a list with from another l

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  13. #13
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Filling rows that are empty that are not all consecutive in a list with from another l

    ...One last enhancement - In this version, the formatting is restored after sorting:
    Please Login or Register  to view this content.
    Hope this is helpful, I enjoyed the challenge. Take care - Lee

+ 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. Replies: 5
    Last Post: 01-07-2014, 10:45 AM
  2. Replies: 1
    Last Post: 09-14-2013, 04:55 AM
  3. How to convert a list into list of consecutive numbers
    By mr. grieves in forum Excel General
    Replies: 6
    Last Post: 05-15-2013, 04:26 PM
  4. [SOLVED] extract only certain values from a list which contains empty rows
    By Teaorchid in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-19-2013, 06:13 PM
  5. list box-hide empty rows
    By sunilmulay in forum Excel General
    Replies: 5
    Last Post: 08-29-2012, 11:30 AM
  6. [SOLVED] remove all the empty rows at the end of my list?
    By rantz in forum Excel General
    Replies: 2
    Last Post: 02-07-2006, 07:00 PM
  7. [SOLVED] Compile List of Rows With an Empty Cell
    By TC in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-18-2005, 08:05 PM
  8. [SOLVED] Compile List of Rows With an Empty Cell
    By TC in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-18-2005, 05:05 PM

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