R G
R G

Reputation: 1

How do I delete defined rows in Google Sheets automatically everyday at midnight?

No idea how to script this myself and googling hasn't helped.

What I want to do:

Delete columns E:H every day at midnight. That's it.

Any help appreciated. Thanks

Upvotes: 0

Views: 370

Answers (1)

Cooper
Cooper

Reputation: 64040

The first function creates a timebased trigger.

function createTimeBasedTrigger() {
  var ss=SpreadsheetApp.openById("SpreadsheetID");
  ScriptApp.newTrigger('deleteEtoH').timeBased().everyDays(1).atHour(0).create();
}

This function deletes columns 5 through 8

function deleteEtoH() {
  var ss=SpreadsheetApp.openById("SpreadsheetID");
  var sh=ss.getSheetByName("Sheet Name");
  sh.deleteColumns(5,4)                          
}

Time Driven Trigger

Class Sheet

Upvotes: 1

Related Questions