# How do I randomize certain stimuli in an excel file full of other stimuli?

**URL:** <https://discourse.psychopy.org/t/how-do-i-randomize-certain-stimuli-in-an-excel-file-full-of-other-stimuli/31525>\
**Category:** Builder\
**Created:** [October 23, 2022, 12:38pm UTC](https://discourse.psychopy.org/t/how-do-i-randomize-certain-stimuli-in-an-excel-file-full-of-other-stimuli/31525 "2022-10-23T12:38:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![skyfiz](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@skyfiz](https://discourse.psychopy.org/u/skyfiz)\
**Post date:** [October 23, 2022, 12:38pm UTC](https://discourse.psychopy.org/t/how-do-i-randomize-certain-stimuli-in-an-excel-file-full-of-other-stimuli/31525/1 "2022-10-23T12:38:14Z")

</div>

I have 24 stimuli in total (all in the same excel file), but I can’t seem to figure out how to make sure only 12 is presented at the same time randomly

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [October 23, 2022, 10:46pm UTC](https://discourse.psychopy.org/t/how-do-i-randomize-certain-stimuli-in-an-excel-file-full-of-other-stimuli/31525/2 "2022-10-23T22:46:28Z")

</div>

What I do is break the loop after the desired number of iterations. For example

```auto
if trials.thisN == 11:
     trials.finished = True

```

This code doesn’t work online in 2022.2.4 but is fine if you set version 2022.1.4 ( in Experiment Settings.
