Home > Mobile >  Google sheet script to shift content once a day
Google sheet script to shift content once a day

Time:05-02

I would like to move the content of B2:F8 to C2:G8 (one column to the right) once a day, at 4am.

How can I achieve that?

CodePudding user response:

You can run AppScript triggers to run your custom function once a Day.

For example, you have a function to do this content shifting in your Apps Script.

Then go to your Triggers > Add Trigger > Choose your function to run once in a day > Select the Select event source to Time Driven > Select type of time-based trigger to Day Timer

That's it. It will run a function once a day or you can customize your event whatever you like

CodePudding user response:

Move Stuff one column to the right

function movestuff() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName("Enter you sheetname");
  sh.getRange("B2:F8").moveTo(sh.getRange("C2:G8"));
}

Run the following function once to create the trigger

function createTrigger() {
  if(ScriptApp.getProjectTriggers().filter(t => t.getHandlerFunction() == "moveStuff").length == 0) {
    ScriptApp.newTrigger("moveStuff").timeBased().everyDays(1).atHour(4).create();
  }
}
  • Related