macro foglio google

121 views
Skip to first unread message

Loris Scarpari

unread,
Jul 21, 2022, 8:39:36 AM7/21/22
to Google Apps Script Community
Ciao a tutti
avrei bisogno di creare una macro che prede dei valori da 5 celle e li trasferisce in una tabella
i valori delle 5 celle cambiano ogni giorno, quindi dee copiare solo i numeri, non la formula
e ogni giorno alle ore 19:00 la macro deve copiare questi valori nella tabella
ma ogni giorno li deve copiare in una colonna diversa
andando da sinistra verso destra
Il risultato che devo ottenere in pratica è una tabella con i 5 valori per ogni giorno dell'anno
La macro che copia i valori sono riuscito a farla, però non so come farle spostare la posizione della destinazione in un'altra colonna ad ogni attivazione della macro, ne come automatizzare l'esecuzione ogni giorno della macro ad una determinata ora, esclusi i sabati e domenica.
Grazie a tutti quelli che mi daranno un aiuto

Alex

unread,
Jul 21, 2022, 9:28:49 AM7/21/22
to Google Apps Script Community
Hi!

Please share your program for a quick solution. It's the best way.

Loris Scarpari

unread,
Jul 21, 2022, 9:39:03 AM7/21/22
to google-apps-sc...@googlegroups.com
This is my program.
I need to copy the 5 values every day at 7pm. except Saturday and Sunday. every day in the next column on the right. in order to have a table with the 5 values for each day.
thank you


function CopiaValori() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('B8').activate();
  spreadsheet.getRange('B1:B5').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_VALUESfalse);
};

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/c5d3a80e-f078-4c07-bfc4-67ce6f1e3720n%40googlegroups.com.

Edward Ulle

unread,
Jul 21, 2022, 10:03:43 AM7/21/22
to Google Apps Script Community
Try this.  You can add the time event trigger from the script editor.

function copyAt7PM() {
  try {
    let spread = SpreadsheetApp.getActiveSpreadsheet();
    let sheet = spread.getSheetByName("Sheet1"); // you need to fill in the sheet name
    let values = sheet.getRange(1,2,5,1); // B1:B5
    sheet = spread.getSheetByName("Sheet2"); // you need to fill in the sheet name
    // getRange(1,getLastColumn()+1,1,5) get the next empty column in the sheet
    sheet.getRange(1,sheet.getLastColumn()+1,5,1).setValues(values);
  }
  catch(err) {
    Logger.log(err);
  }
}

Untitled.png

Loris Scarpari

unread,
Jul 21, 2022, 10:41:55 AM7/21/22
to google-apps-sc...@googlegroups.com
Ok. But how can i paste in the next column every time ? non always in the same column

Edward Ulle

unread,
Jul 21, 2022, 11:01:53 AM7/21/22
to Google Apps Script Community
Everytime the values are placed in a new column, the next time it runs the getLastColumn() will be one greater than the previous.  So it will always add values to a new column to the right.
Reply all
Reply to author
Forward
0 new messages