+ Reply to Thread
Results 1 to 7 of 7

Filling empty cells with random values from a list

Hybrid View

  1. #1
    Registered User
    Join Date
    06-25-2023
    Location
    Cebu City
    MS-Off Ver
    Microsoft Office Mondo 2016
    Posts
    5

    Filling empty cells with random values from a list

    Hello everyone.

    I'm trying to fill in the empty cells randomly with a list of values, but these values cannot be duplicated on the same row and column, and can only be duplicated a set number of times.

    I'll attach the sheet here.
    I want to fill in the empty cells of the "Time/Teacher" table with the names from the "Student Name" list, but the student name cannot be duplicated within the same column and row, and can only be duplicated 5 times (# of classes)

    Any advice would be greatly appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Filling empty cells with random values from a list

    I think my formula is not so good, other should be done better.
    (It's not random just sequence)

    Regards.

    Please try.

    F2 copy to J5
    =INDEX($A$2:$A$9,
    IF(MOD(((ROWS($F$1:$F1)-1)*5)+COLUMNS($F$1:F$1),COUNTA($A$2:$A$9))=0,COUNTA($A$2:$A$9),
    MOD(((ROWS($F$1:$F1)-1)*5)+COLUMNS($F$1:F$1),COUNTA($A$2:$A$9)))
    )

    F7 copy to J10
    =INDEX($A$2:$A$9,
    IF(MOD(((ROWS($F$1:$F5)-1)*5)+COLUMNS($F$1:F$1),COUNTA($A$2:$A$9))=0,COUNTA($A$2:$A$9),
    MOD(((ROWS($F$1:$F5)-1)*5)+COLUMNS($F$1:F$1),COUNTA($A$2:$A$9)))
    )

  3. #3
    Registered User
    Join Date
    06-25-2023
    Location
    Cebu City
    MS-Off Ver
    Microsoft Office Mondo 2016
    Posts
    5

    Re: Filling empty cells with random values from a list

    Thank you for your help. I will keep this as a reference for future excel tasks.

  4. #4
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Filling empty cells with random values from a list

    Please empty the cells with LUNCH and try in F2 for the whole table inclusive LUNCH:
    Formula: copy to clipboard
    =LET(r,SORTBY(SEQUENCE(8),RANDARRAY(8)),s,SORTBY(SEQUENCE(8),RANDARRAY(8)),SORTBY(EXPAND(MAKEARRAY(8,5,LAMBDA(x,y,INDEX(A2:A9,1+MOD(INDEX(s,x)+INDEX(r,y),8)))),9,5,"LUNCH"),{1;2;3;4;6;7;8;9;5}))
    Press F9 for a new random result.
    Attached Files Attached Files
    Last edited by HansDouwe; 06-26-2023 at 07:27 AM.

  5. #5
    Registered User
    Join Date
    06-25-2023
    Location
    Cebu City
    MS-Off Ver
    Microsoft Office Mondo 2016
    Posts
    5

    Re: Filling empty cells with random values from a list

    That's awesome! It's amazing seeing everything get randomized every time I press F9. Thanks a lot for helping!
    Hope you guys have a nice day, always.

  6. #6
    Registered User
    Join Date
    06-25-2023
    Location
    Cebu City
    MS-Off Ver
    Microsoft Office Mondo 2016
    Posts
    5

    Re: Filling empty cells with random values from a list

    I apologize, I had one last question. If I were to add in more students and Teachers, which parts of your code should I alter?

  7. #7
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Filling empty cells with random values from a list

    When there are more students, are there also (just as many) more hours?
    If that is not the case, additional rules are required: Should several students be assigned to 1 teacher at some hours?
    Or are there students who do not come to certain teachers.

+ 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. [SOLVED] Macro to Fill Cells With Random Values From A List
    By brent_milne in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-18-2022, 07:53 PM
  2. Replies: 12
    Last Post: 02-11-2018, 05:31 AM
  3. Creating list of random numbers based on values in other cells
    By rossjohnston in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-01-2015, 10:08 AM
  4. Replies: 1
    Last Post: 05-26-2014, 01:31 PM
  5. [SOLVED] Extract values from a list containing empty cells
    By Bibendum in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-07-2012, 11:59 AM
  6. Filling empty cells
    By bukimiak in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-17-2011, 08:14 AM
  7. Filling empty cells with a value
    By Ian Richardson ACITP in forum Excel General
    Replies: 4
    Last Post: 05-17-2006, 10:30 AM

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