# Script for Autofill of Formula in column

**URL:** <https://community.glideapps.com/t/script-for-autofill-of-formula-in-column/7799>\
**Category:** Ask for Help\
**Created:** [April 25, 2020, 8:12am UTC](https://community.glideapps.com/t/script-for-autofill-of-formula-in-column/7799 "2020-04-25T08:12:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathan\_kumar](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mathan_kumar/32/1146_2.png) [@Mathan\_kumar](https://community.glideapps.com/u/Mathan_kumar)\
**Post date:** [April 25, 2020, 8:12am UTC](https://community.glideapps.com/t/script-for-autofill-of-formula-in-column/7799/1 "2020-04-25T08:12:13Z")

</div>

Somebody help me to get script in google sheets for autofill of formula in a column.

```auto
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('DUE');
  ss.getRange("G2").setFormula("=if(D:D=false, C2*1, C2*0)");
  
  var lr=ss.getLastRow();
  var fillDownRange = ss.getRange(2, 7, lr-1);
  ss.getRange("G2").copyTo(fillDownRange);

```

Above script is working well, but i want to change in formula ,i.e.

```auto
 ss.getRange("H2").setFormula("=if(D:D=false, "Not Paid", " Paid")");

```

but this is making error, kindly suggest any other substitute formula

**Thanks in Advance**

---

<div class="post-metadata">

**Author:** ![sardamit](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/sardamit/32/263_2.png) [@sardamit](https://community.glideapps.com/u/sardamit)\
**Post date:** [April 25, 2020, 9:06am UTC](https://community.glideapps.com/t/script-for-autofill-of-formula-in-column/7799/2 "2020-04-25T09:06:48Z")

</div>

Use “” before every double-quote.

---

<div class="post-metadata">

**Author:** ![Mathan\_kumar](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mathan_kumar/32/1146_2.png) [@Mathan\_kumar](https://community.glideapps.com/u/Mathan_kumar)\
**Post date:** [April 25, 2020, 9:22am UTC](https://community.glideapps.com/t/script-for-autofill-of-formula-in-column/7799/3 "2020-04-25T09:22:14Z")

</div>

Sorry, its not working. 😢

---

<div class="post-metadata">

**Author:** ![Naos\_Wilbrink](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/naos_wilbrink/32/769_2.png) [@Naos\_Wilbrink](https://community.glideapps.com/u/Naos_Wilbrink)\
**Post date:** [April 25, 2020, 12:19pm UTC](https://community.glideapps.com/t/script-for-autofill-of-formula-in-column/7799/4 "2020-04-25T12:19:44Z")

</div>

It seems like you could achieve the same thing using ARRAY FORMULAS. Apart from that you can try replacing " with ’ (single quote) OR use “”" (3 quotes) OR /" (slash quote)

Those are the most coming escapes.

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [April 25, 2020, 12:41pm UTC](https://community.glideapps.com/t/script-for-autofill-of-formula-in-column/7799/5 "2020-04-25T12:41:55Z")

</div>

Autofill column = arrayformula for sure.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 25, 2020, 1:12pm UTC](https://community.glideapps.com/t/script-for-autofill-of-formula-in-column/7799/6 "2020-04-25T13:12:31Z")

</div>

The corresponding formula to set it H2 should be:

=ARRAYFORMULA(IF(D:D\<\>"",IF(D:D=FALSE,“Not paid”,“Paid”),""))

I added a condition to filter out empty rows in D to not get your app up to 500 rows in case you are using a free version.

Please reply back if you need further help.

---

<div class="post-metadata">

**Author:** ![Mathan\_kumar](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mathan_kumar/32/1146_2.png) [@Mathan\_kumar](https://community.glideapps.com/u/Mathan_kumar)\
**Post date:** [April 25, 2020, 5:48pm UTC](https://community.glideapps.com/t/script-for-autofill-of-formula-in-column/7799/7 "2020-04-25T17:48:38Z")

</div>

Thanks @Naos_Wilbrink your **'(single quote)** saved my day. 😄

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [April 25, 2020, 6:26pm UTC](https://community.glideapps.com/t/script-for-autofill-of-formula-in-column/7799/8 "2020-04-25T18:26:39Z")

</div>

Wouldn’t if be easier to just create an If/then column in Glide? Or is this a sheet that’s not used in Glide or you need to see the values in the google sheet? In that case an arrayformula would be much simpler than a script. If it’s working, don’t worry about. Just want to make sure you’re aware of all your options.
