# Randomize a picture carousel - possible?

**URL:** <https://community.glideapps.com/t/randomize-a-picture-carousel-possible/12322>\
**Category:** Ask for Help\
**Created:** [July 11, 2020, 6:59pm UTC](https://community.glideapps.com/t/randomize-a-picture-carousel-possible/12322 "2020-07-11T18:59:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luberdelle](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/luberdelle/32/10419_2.png) [@Luberdelle](https://community.glideapps.com/u/Luberdelle)\
**Post date:** [July 11, 2020, 6:59pm UTC](https://community.glideapps.com/t/randomize-a-picture-carousel-possible/12322/1 "2020-07-11T18:59:18Z")

</div>

Hi there,  
Does anyone know whether it’s possible to randomize a picture carousel? I know how to create one, but it’s always pic 1 that comes first, pic 2 that comes second, etc. I’d like the pictures to appear randomly.

thx

---

<div class="post-metadata">

**Author:** ![mthakershi](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mthakershi/32/1715_2.png) [@mthakershi](https://community.glideapps.com/u/mthakershi)\
**Post date:** [July 11, 2020, 8:44pm UTC](https://community.glideapps.com/t/randomize-a-picture-carousel-possible/12322/2 "2020-07-11T20:44:50Z")

</div>

Don’t know if it applies to your need but I randomize image URL links in my backend sheet using a script.

---

<div class="post-metadata">

**Author:** ![Luberdelle](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/luberdelle/32/10419_2.png) [@Luberdelle](https://community.glideapps.com/u/Luberdelle)\
**Post date:** [July 12, 2020, 1:14am UTC](https://community.glideapps.com/t/randomize-a-picture-carousel-possible/12322/3 "2020-07-12T01:14:48Z")

</div>

It could. What kind of script do I need to use then? THX.

---

<div class="post-metadata">

**Author:** ![mthakershi](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mthakershi/32/1715_2.png) [@mthakershi](https://community.glideapps.com/u/mthakershi)\
**Post date:** [July 13, 2020, 3:35am UTC](https://community.glideapps.com/t/randomize-a-picture-carousel-possible/12322/4 "2020-07-13T03:35:30Z")

</div>

In my case, I have image URLs in a column (AR) in the “Master Options” sheet.  
I generate a random number between 2 and 12 then use the number to fetch the value from X cell. Assign it in to the other sheet where image is actually being displayed. Maybe you can use this for your purpose. The following code is then triggered by google sheets trigger on a periodic bases.

```
  // Change certain picture or background images - start
  // Start - A2
  // Select from Master Options - AR2 to AR12
  // Based on values in AR in Master Options, 12 needs to change with it
      const min = 2,
        max = 12; // this can be different for you
      let ss = SpreadsheetApp.getActiveSpreadsheet();

      let randNum = Math.floor(Math.random() * (max - min + 1)) + min;
      let readVal = ss
        .getSheetByName("Master Options")
        .getRange("AR" + randNum)
        .getValue();
      if (!readVal)
        readVal = ss.getSheetByName("Master Options").getRange("AR2").getValue();
      ss.getSheetByName("Start").getRange("A2").setValue(readVal);
```

---

<div class="post-metadata">

**Author:** ![Luberdelle](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/luberdelle/32/10419_2.png) [@Luberdelle](https://community.glideapps.com/u/Luberdelle)\
**Post date:** [July 14, 2020, 7:52am UTC](https://community.glideapps.com/t/randomize-a-picture-carousel-possible/12322/5 "2020-07-14T07:52:11Z")

</div>

OK, thanks for answering. I’m afraid I’m not to that level yet but I’ll keep this in mind, thx!
