0
votes

I need a simple script for Google sheet which will automatically daily will do simple task - copy a 3 cell's values and paste into another 3 cells as a plain text.

Is anyone can help me?

2
Be more detailed, which three cells to copy and which three cells to paste the data? - Brondby IF

2 Answers

0
votes

Assuming your spreadsheet page is named PAGE 1 and you want to copy the data from A1 to A3 and paste it into the same PAGE 1 in cells B1 through B3, this is the script to use:

function MyFunction() {
  var ss = SpreadsheetApp.getActive();
  ss.getRange('Page 1!A1:A3').copyTo(ss.getRange('Page 1!B1:B3'), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
}
0
votes

To achieve what you want to do. I recommend you to use the Time-driven triggers, which help you to trigger events every "n" time (mins, hours, days). Follow these steps to configure the Time-driven triggers.

1) Go to your Apps Script project

2) Click Edit->Current project's triggers

3) Click "+ Add Trigger"

4) Select :

  • Choose which function to run -> setTimeTrigger
  • Select event source->Time-driven
  • Select type of time based trigger->Day timer

  • Select time of day->[Hour you want]

5) Click Save

6) Use this code in your Apps Script project:

// Name this function as "setTimeTrigger"
function setTimeTrigger(){
  // Get first sheet in the active Spreadsheet
  var ss = SpreadsheetApp.getActive().getSheets()[0];
  // Parameters you set
  var sourceVals = "A1:A3";
  var destination = "B1:B3";
  // Copy and paste the values where you want to
  ss.getRange(sourceVals).copyTo(ss.getRange(destination));
}

Docs

You can learn more about triggers and Spreadsheet Class in the following docs: