2

I want to randomly pick a name that matches specific criteria. See for example the image:

enter image description here

How can I filter a list, each one with associated data in other columns, using provided criteria, then pick randomly one record?

I can use VB if needed, I'm not restricted to formulas in cells.

  • Do you mean "How to randomly filter a list based on multiple criteria in Excel?" || coz the title said "filtered" but "how can I filter.." & "Randomly picking a cell among a simple array is easy.." is in the question body. – p._phidot_ Jan 10 at 10:38
0

The best result so far is:

  • Data -> enable filter on the list
  • set the filtering criteria using VBA:

    Sheets(mySheet).Range(myRange).AutoFilter Field:=2, Criteria1:="<>" & myValue

  • copy only visible cells to another place:

    Sheets(mySheet).Range(myRange).SpecialCells(xlCellTypeVisible).Copy Sheets(myNewSheet).Range(myNewRange).PasteSpecial Paste:=xlValues

  • pick a random cell from the resulting list:

    =INDEX('myNewSheet'!myNewRange;RANDBETWEEN(1;COUNTA('myNewSheet'!myNewRange)))

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.