# Populating multipls tabs from one tab in google-sheet

**URL:** <https://community.glideapps.com/t/populating-multipls-tabs-from-one-tab-in-google-sheet/11716>\
**Category:** Ask for Help\
**Created:** [June 30, 2020, 9:08am UTC](https://community.glideapps.com/t/populating-multipls-tabs-from-one-tab-in-google-sheet/11716 "2020-06-30T09:08:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![adelhammoud](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/adelhammoud/32/5587_2.png) [@adelhammoud](https://community.glideapps.com/u/adelhammoud)\
**Post date:** [June 30, 2020, 9:08am UTC](https://community.glideapps.com/t/populating-multipls-tabs-from-one-tab-in-google-sheet/11716/1 "2020-06-30T09:08:22Z")

</div>

I have a registration form that adds a new row into tab=Order\_Form with Company Info and Contact info Email. Based on such received data (the system will generate a unique Client\_Id).  
I like to  
Add a new row to tab=companies to add this new company info & tag it with this new Client\_Id.  
Add a new row to tab=contacts to add this new contact info & tag it with this new Client\_Id.  
Add a new row to tab=Users to activate this contact as a user & tag it with this new Client\_Id.  
Add 10 rows to tab=Apps & tag them also with this new Client\_Id.

So, data from one tab into 4 tabs.  
Glide doesn’t allow me to call a FORM from the main Form - else, I can build a wizard (at first time login).  
Trying to stay away from Zapiers.

Any pointers!!

---

<div class="post-metadata">

**Author:** ![Christophe\_HK](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/christophe_hk/32/4161_2.png) [@Christophe\_HK](https://community.glideapps.com/u/Christophe_HK)\
**Post date:** [June 30, 2020, 11:25am UTC](https://community.glideapps.com/t/populating-multipls-tabs-from-one-tab-in-google-sheet/11716/2 "2020-06-30T11:25:36Z")

</div>

A Google apps script based on the Onchange trigger will be your friend, free of charge and not so complex 😉

---

<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:** [June 30, 2020, 12:20pm UTC](https://community.glideapps.com/t/populating-multipls-tabs-from-one-tab-in-google-sheet/11716/3 "2020-06-30T12:20:26Z")

</div>

I do the exact same thing using a script.

> [@Email registration reference](https://community.glideapps.com/t/email-registration-reference/2156/2):
>
> App:Logins would be the place to get emails. You can use a UNIQUE formula in a new sheet to build a list, but you could run into problems if have other columns in your new sheet that need to match up to the email being pulled from App:Logins. I wouldn’t trust googles UNIQUE function in this case. Things can get out of whack if you’re not careful, as the order of emails could change. Instead I would use a script that will check for unique emails and apply them to another sheet. I use the fol…

---

<div class="post-metadata">

**Author:** ![adelhammoud](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/adelhammoud/32/5587_2.png) [@adelhammoud](https://community.glideapps.com/u/adelhammoud)\
**Post date:** [June 30, 2020, 6:18pm UTC](https://community.glideapps.com/t/populating-multipls-tabs-from-one-tab-in-google-sheet/11716/4 "2020-06-30T18:18:08Z")

</div>

Easy said than done for someone who never worked on google apps scripts 🙂

Let me see if I can get creative with Arrayformulas and palce-holders - unless there is a ready-made script that I can simply learn how to tweak and plug in. (

---

<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:** [June 30, 2020, 8:50pm UTC](https://community.glideapps.com/t/populating-multipls-tabs-from-one-tab-in-google-sheet/11716/5 "2020-06-30T20:50:22Z")

</div>

My previous attached post includes the script I use. All it needs is a sheet id from your sheet, change the source and destination sheet tabs, and alter the beginning row and column to copy. In my case, my script reflects that the data I want to copy starts on row 3 and I am copying any new unique cell values in column A to column A in the other sheets tabs.

At the time of that post, I was copying unique student names to other sheets, which are accessed via relations in Glide. Now I copy RowIDs, but the concept is still the same.

---

<div class="post-metadata">

**Author:** ![adelhammoud](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/adelhammoud/32/5587_2.png) [@adelhammoud](https://community.glideapps.com/u/adelhammoud)\
**Post date:** [July 1, 2020, 6:58am UTC](https://community.glideapps.com/t/populating-multipls-tabs-from-one-tab-in-google-sheet/11716/6 "2020-07-01T06:58:41Z")

</div>

Thanks Jeff - my setup is a bit different, here’s a simplified presentation of what I’m trying to achieve.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/3/31d2fa752f40f11d0a7893799840b87abab00c22.png)

---

<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:** [July 6, 2020, 11:56pm UTC](https://community.glideapps.com/t/populating-multipls-tabs-from-one-tab-in-google-sheet/11716/7 "2020-07-06T23:56:39Z")

</div>

The concept would be the same. Instead of a single function to copy\_new\_names, you could probably create separate functions to handle each sheet you are adding to. I would also possibly make a duplicate of subscriber and date in between company name and contact email to the getrange in the script works. There are probably better ways to handle this, such as concatenating the 3 columns into one column with a delimiter (such as a pipe “|” or a comma “,”), writing that to the first column like my original script, then performing a split on the delimiter to fill the 3 columns. Shouldn’t really matter.

I modified my original script to hopefully fit your scenario. It’s not tested, so hopefully it works. Again, this assumes that you duplicate the subscriber and date columns after the company\_name column.

` // You can activate a trigger on function copy\_new\_names()  
// Assuming that row 1 and 2 in each sheet is not included in the values to be processed…

```
function CopyName() {
  var SheetID = ' *****Your Sheet ID Here*****'
  if (SpreadsheetApp.getActiveSheet().getName() == "Contacts") {
    copy_companies('Contacts', 'Companies', SheetID);
    copy_users('Contacts', 'Users', SheetID);
  }
}    

function copy_companies(SheetFrom, SheetTo, SheetID) {
  var spreadsheet = SpreadsheetApp.openById(SheetID);
  var sheet = spreadsheet.getSheetByName(SheetFrom);
  var sheet2 = spreadsheet.getSheetByName(SheetTo);
  var endrow = sheet.getLastRow(), endcol = sheet.getLastColumn();
  var endrow2 = sheet2.getLastRow(), endcol2 = sheet2.getLastColumn();
  // assuming that row 1 is not included in the values to be processed
  var valuesSheet1 = sheet.getRange(2, 1, endrow-1, 3).getValues(), valuesSheet2 = [];
  if ( endrow2 > 1 ) valuesSheet2 = sheet2.getRange(2, 1, endrow2-1, 3).getValues();
  valuesSheet2 = [i for each (i in valuesSheet2)if ((i)[0].trim()!="")];

  var newlist = checkNameList(valuesSheet1, valuesSheet2);
  //Below to paste new list in sheet2 
  sheet2.getRange(2, 1, newlist.length, 3).setValues(newlist);
}

function copy_users(SheetFrom, SheetTo, SheetID) {
  var spreadsheet = SpreadsheetApp.openById(SheetID);
  var sheet = spreadsheet.getSheetByName(SheetFrom);
  var sheet2 = spreadsheet.getSheetByName(SheetTo);
  var endrow = sheet.getLastRow(), endcol = sheet.getLastColumn();
  var endrow2 = sheet2.getLastRow(), endcol2 = sheet2.getLastColumn();
  // assuming that row 1 is not included in the values to be processed
  var valuesSheet1 = sheet.getRange(2, 4, endrow-1, 6).getValues(), valuesSheet2 = [];
  if ( endrow2 > 1 ) valuesSheet2 = sheet2.getRange(2, 1, endrow2-1, 3).getValues();
  valuesSheet2 = [i for each (i in valuesSheet2)if ((i)[0].trim()!="")];

  var newlist = checkNameList(valuesSheet1, valuesSheet2);
  //Below to paste new list in sheet2 
  sheet2.getRange(2, 1, newlist.length, 3).setValues(newlist);
}

function checkNameList(valuesSheet1, valuesSheet2) {
  var values1 = valuesSheet1.map(function(d) { return d.join()}), values2 = [];
  if ( valuesSheet2.length ) values2 = valuesSheet2.map(function(d) { return d.join()});
  var newList = [];
    for ( var i in values1 ) {
      if ( values2.indexOf(values1[i]) === -1 && values1[i].length>0) newList.push([values1[i]]);
    }  
  newList = valuesSheet2.concat(newList);
  //Logger.log(newList)
  return newList;
}`
```

---

<div class="post-metadata">

**Author:** ![adelhammoud](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/adelhammoud/32/5587_2.png) [@adelhammoud](https://community.glideapps.com/u/adelhammoud)\
**Post date:** [July 7, 2020, 1:13pm UTC](https://community.glideapps.com/t/populating-multipls-tabs-from-one-tab-in-google-sheet/11716/8 "2020-07-07T13:13:10Z")

</div>

Many thanks Jeff - will follow such steps. Much appreciated.
