Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

117
Vistas
Have function run daily on specific sheet in Google Sheets

I am copying some data from a sheet on one spreadsheet to a sheet on a separate spreadsheet. I want this function to run everyday, but I only want it to run on the sheets that the user has manually run it on. There are other sheets in the source Spreadsheet that have private information that cannot be shared on the destination Spreadsheet.

function onOpen(e) {
 SpreadsheetApp.getUi()
     .createMenu('My Menu')
     .addItem('Create Read-Only', 'copyInfo')
     .addToUi();
}

// Copies all info to a new sheet in Check Submission
function copyInfo() {
 
 var copySheet = SpreadsheetApp.getActiveSheet();
 var sheetName=copySheet.getName();
 var pasteSpreadsheet = SpreadsheetApp.openById("1NXmdq6yCKC6oiDAQNXcovj85697__rCeVJiIT_ou_gI")

 //Create new sheet if one doesn't exist
 var newSheet = pasteSpreadsheet.getSheetByName(sheetName);

   if (newSheet != null) 
   pasteSpreadsheet.deleteSheet(newSheet);
   newSheet = pasteSpreadsheet.insertSheet();
   newSheet.setName(sheetName);

 //Copy and paste data
 
 // Clear the Google Sheet before copy
 newSheet.clear({contentsOnly: true});

 // get source range
 var source = copySheet.getRange("B2:B");
 var values = source.getValues();
 // get destination range
 var destination = newSheet.getRange(1,1,values.length,values[0].length);
  // copy values to destination range
 destination.setValues(values)
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda