# Formula create on new ron insert google shgeets

**URL:** <https://community.glideapps.com/t/formula-create-on-new-ron-insert-google-shgeets/59560>\
**Category:** Ask for Help\
**Created:** [March 23, 2023, 7:02am UTC](https://community.glideapps.com/t/formula-create-on-new-ron-insert-google-shgeets/59560 "2023-03-23T07:02:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenneth\_Camilleri](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/kenneth_camilleri/32/56090_2.png) [@Kenneth\_Camilleri](https://community.glideapps.com/u/Kenneth_Camilleri)\
**Post date:** [March 23, 2023, 7:02am UTC](https://community.glideapps.com/t/formula-create-on-new-ron-insert-google-shgeets/59560/1 "2023-03-23T07:02:16Z")

</div>

Hi i am trying to add to rows togather when a new row is creted via Gile in google sheets

I need to add row D and Row E in Row F on a new entry but it keeps on replacing the formula or jumping to next light with no formula can soemone pelase help

---

<div class="post-metadata">

**Author:** ![Kenneth\_Camilleri](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/kenneth_camilleri/32/56090_2.png) [@Kenneth\_Camilleri](https://community.glideapps.com/u/Kenneth_Camilleri)\
**Post date:** [March 23, 2023, 8:42am UTC](https://community.glideapps.com/t/formula-create-on-new-ron-insert-google-shgeets/59560/2 "2023-03-23T08:42:00Z")

</div>

I have found this script that works but i need to ammend it. I need to make sum on current row creation

Column D+E and answer comes on column F

function onOpen() {  
var sheet = SpreadsheetApp.getActiveSpreadsheet();  
ScriptApp.newTrigger(‘addFormula’)  
.forSpreadsheet(sheet)  
.onEdit()  
.create();  
}

function addFormula(e) {  
var sheet = e.source.getActiveSheet();  
var range = e.range;  
var row = range.getRow();  
var col = range.getColumn();  
if (col == 1) {  
var formula = "=SUM(IMPORTRANGE("[https://docs.google.com/spreadsheets/d/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/edit#gid=0\“,\“Sheet1!A\”&ROW()-1\”:B\“&ROW()))”](https://docs.google.com/spreadsheets/d/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/edit#gid=0%5C%22,%5C%22Sheet1!A%5C%22&ROW()-1%5C%22:B%5C%22&ROW()))%22);  
sheet.getRange(row, 3).setFormula(formula);  
}  
}

---

<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:** [March 23, 2023, 11:46am UTC](https://community.glideapps.com/t/formula-create-on-new-ron-insert-google-shgeets/59560/3 "2023-03-23T11:46:09Z")

</div>

I think you are making this much too complicated. You can simply use a Math column to do your calculation in Glide. No need to rely on formulas in your google sheet.
