title: Script setValue based on the values of column based on value of other column matching reference
body: <p><a href="https://docs.google.com/spreadsheets/d/1g5mLRcwBb9rLaJ4qIUy1PLaBNNfuwvXwct1cBr2QVgk/edit#gid=1271563337" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1g5mLRcwBb9rLaJ4qIUy1PLaBNNfuwvXwct1cBr2QVgk/edit#gid=1271563337</a></p>
  <p>basicly im trying to figure out a script that would:</p>
  <ul>
  <li>Find match in <strong>Relação!A:A</strong> to content of <strong>Config!B3</strong>
  <ul>
  <li>in my example <em><strong>ABEV3</strong></em> it would be <strong>Relação!A3</strong></li>
  <li>that would find a correponding row 3</li>
  </ul>
  </li>
  <li>so the matching cel in <strong>Relação!L:L</strong> would be <strong>Relação!L3</strong></li>
  <li>update <strong>Relação!L3</strong> with content of <strong>Config!D9</strong></li>
  </ul>
  <hr />
  <p>basic idea with part of code that i can do to try to ilustrate</p>
  <pre><code>function setSheetID()
  { 
  
    const ss = SpreadsheetApp.getActiveSpreadsheet()
    const sheet_c = ss.getSheetByName('Config');
  
    var ticket = ss.getRange(3,2,1,1).getValues(); // Config!B3
    var sheetID = ss.getRange(9,4,1,1).getValues(); // Config!D9
  
    const sheet_r = ss.getSheetByName('Relação');
  
    var LR = sheet_r.getLastRow(); 
    var LC = sheet_r.getLastColumn();
  
    var row_to_match_with_ticket = sheet_r.getRange(1,1,LR,1).getValues(); // Relação!A:A
  
  // that part i have no idea how to get range for target where ticket would match with row_to_match_with_ticket, so i will put the result as example
  
    for (var i = 0; i &lt;= 1; i++) // i dont understand that, just setting exemple from posts ive seen
    {
      if (row_to_match_with_ticket[i] == ticket ) 
      {  
        var target = sheet_r.getRange(3,12,1,1);  // Relação!L3 // im harcoding result, cos i dont fully understant what i wrote in the example 
  
        sheet_r.getRange(target).setValues(sheetID);
      }
    } 
  
  };
  </code></pre>
  <hr />
  <p>now i will try to ilustrate with a query: (im not in USA, so ; instead of ,)</p>
  <ul>
  <li><p>to find my target:</p>
  <p>query('Relação'!A:L; &quot;SELECT L WHERE (A = '&quot;&amp;Config!B3&amp;&quot;') LIMIT 1&quot;;0)</p>
  </li>
  <li><p>update that cell</p>
  </li>
  </ul>
  <hr />
  <ul>
  <li>UPDATE WITH <strong>Config!D9</strong> ( <strong>Relação!L:L</strong> WHERE <strong>Relação!A:A</strong> = <strong>Config!B3</strong> )</li>
  <li>in this case update <strong>Relação!L3</strong> WITH VALUES OF <strong>Config!D9</strong></li>
  </ul>
  <p>searched and results where too complex to me understand and be able to try to adapt to my needs</p>
  <p>thanks in advance</p>
  <p>Edit: tried to simplify, to make it easier to understand as im terrible to explain aparently, but that script would run on multiple SS that i quite often replace as i improve it, so i need each sheet to update a main sheet</p>
  <p>Edit 2: tried to provide a logical way to understant the inputs and outputs, its might be easier to see in the sheet i provided as its comented and colored, tried to describe the best possible way i could</p>
  <p>Edit 3: added basic code to try to show what i want to do</p>