title: Is there a way to script for "refreshing" a given tab?
body: <p>So essentially, I create a copy of a spreadsheet for each new client, and I have a workout program template tab (&quot;Week Template&quot;) that I duplicate and re-name based upon the week (Week 1, Week 2, Week 3, etc.). I have another tab called &quot;Data&quot; which pulls data from the week tabs, and sorts it according to the tab/sheet name.</p>
  <p>I'm using this function for tracking data:
  <em>=if('Week 1'!$A4=&quot;SQ&quot;,PRODUCT('Week 1'!$E4,'Week 1'!$K4,'Week 1'!$L4),&quot;&quot;)</em>
  In this instance, I'm tracking data when the SQ identifier is present.</p>
  <p>My issue is that whenever I re-create, say &quot;Week 1&quot;, the data won't auto-populate over on &quot;Data&quot; and shows #REF!. However, whenever I double click on the desired cell, it's almost as if the cell refreshes, and then provides the correct data. I believe this because the function is losing its original data source, and can't &quot;re-connect&quot;.</p>
  <p>As far as I can tell, there isn't a way for this to work natively on Google Sheets, so I'm wondering if there's a way to write a script to work around this issue.</p>
  <p>Sheet: <a href="https://docs.google.com/spreadsheets/d/1KqSGcIAn_X4v0YtGnGZVXaY4Je6B5SS5tz70Mw6U9uk/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1KqSGcIAn_X4v0YtGnGZVXaY4Je6B5SS5tz70Mw6U9uk/edit?usp=sharing</a></p>
  <p>Screenshots = <a href="https://imgur.com/a/ZCLaM1V" rel="nofollow noreferrer">https://imgur.com/a/ZCLaM1V</a></p>
  <p>Here's a script that works as intended, however, it only works when triggered from the Editor menu, I would like it to update automatically:</p>
  <pre><code>function updateDataTab() {
    
    let ss = SpreadsheetApp.getActive();
    let sheet = ss.getSheetByName(&quot;Data&quot;);
    let range = sheet.getRange(3, 1, 60, 77);
    let formulas = range.getFormulas();
    range.clearContent();
    SpreadsheetApp.flush();
    range.setFormulas(formulas);
  
  }
  </code></pre>
  <p>Any and all help is greatly appreciated as I'm quite new to coding.</p>
  <p>Edit: added code
  Edit 2: Added clarification</p>