Search code examples
google-sheetsrandomgoogle-sheets-formulaspreadsheet

How to populate a new 50 cell column in Google sheets with randomly selected data from an existing column?


I don't have much coding experience and not familiar with Google sheets and am only using it for a specific personal project. The idea is that I have a sheet populated with 50+ responses from a google form and I want to return a random selection of exactly 50 of those responses. The responses from the form take in data that will span to column I, but I only need to randomly return 3 of these columns (say B, E, and H for example) of the winnings responses and have this done 50x without any response being selected more than once. What is the formula I would need to do this? Additionally, as I know the google form responses won't populate the spreadsheet beyond column I, is there a way I can automate this process to take place in column J without having to select 50 cells in column J and then running the formula? I've thought the answer would be somewhere on the internet but I've yet to find anything I can use. Thank you.

As I stated before I don't have much coding experience so I haven't tried working this out myself yet. After looking into it a bit I know I need to use VLOOKUP to get the specific data I need from the 50 winners and perhaps RANDOMARRAY, but beyond that I am not sure how to go about this.


Solution

  • Use sortn() and randarray(), like this:

    =sortn({B2:B,E2:E,H2:H}, 50, 0, randarray(rows(B2:B)) * sign(len(A2:A)), false)
    

    See sortn() and randarray().