Posts

Showing posts with the label google-apps-script

Move data to bottom of sheet

Move data to bottom of sheet I've got a list of dates, clients, and shift data in a spreadsheet (rows A5:D34). I want to write this data to the last row of the sheet. Unfortunately, the number of rows is variable. On one week, the data may be 17 rows; later, it may be 23 rows. I want to "archive" the data by moving the used rows to the bottom of the sheet. I'm looking for a code (google script) solution that can work with the fact that the range to be copied is always 4 columns wide, but a variable number of rows. Thanks for all your help! You can set the range to the number of rows. The data to write needs to be a 2D array. The number of inner arrays is the number of rows to write. Look at the documentation for getRange(start row, start column, number of rows to get, number of columns to get) – Sandy Good Jul 1 at 22:17 ...

How to run a function with optional argument/parameter in Google Apps Script

How to run a function with optional argument/parameter in Google Apps Script I am trying to run a function which has an optional argument/parameter in Google Apps Script. The function will create a Google Document and will also create a Google Slide if the user selects Yes. My problem is when the extractReplace function is being called, an error will occur because the copySlide is not defined. Here's how I'm calling the function: var copyId = DriveApp.getFileById(documentTemplate) .makeCopy(documentName + folderName, nsdestinationFolder) .getId(); var copyDocument = DocumentApp.openById(copyId); var copyBody = copyDocument.getActiveSection(); //call function to create technical slide proposal if(createTemplate == "Yes"){ createSlideProposal(); } else{ extractReplace(copyBody, copySlide = 0); } I have tried copySlide = 0, false, null, but it did not work as the copySlide is not defined when is passes to the copySlide.replaceAllText ...