Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>here is a suggestion :</p> <pre><code>/* let us say source array with name(columnA) &amp; ID(columnB) is array 'source' and target array with only IDs is array 'target', you get these with something like*/ var source = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getDataRange().getValues(); // and var target = SpreadsheetApp.getActiveSpreadsheet().getSheets()[1].getDataRange().getValues();// if other columns, change index values in the arrays : 0=A, 1=B ... // then let's create a 3 rd array that will be the new target with ID + names, and call it 'newtarget' var newtarget=new Array() // the iteration could be like this : for(i=0;i&lt;target.length;++i){ // don't miss any ID for(j=0;j&lt;source.length;++j){ // iterate through source to find the name if(target[i][0].toString().match(source[j][1].toString()) == source[j][1].toString()){ var newtargetrow=[source[j][0],target[i][0]] // if match found, store it with name (idx0) and ID (idx 1) }else{ var newtargetrow=['no name found',target[i][0]] // if no match, show it in name column } newtarget.push(newtargetrow);// store result in new array with 2 columns } //loop source } // loop target /* now you have a newtarget array that can directly overwrite the old target using setValues() */ var sh = SpreadsheetApp.getActiveSpreadsheet().getSheets()[1];// assuming the target sheet is sheet nr2 sh.getRange(1,1,newtarget.length,newtarget[0].length).setValues(newtarget); // </code></pre> <p>note I didn't test this code but it should give you a starting point. I made comparison on strings with a .match but you could use other comparisons (direct equality between array elements)... you could also remove spaces in IDs if there is a risk of undesired spaces in the sheet data... I don't know your data so it's up to you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload