-
Notifications
You must be signed in to change notification settings - Fork 0
/
copyDataOnceADay().gs
23 lines (18 loc) · 995 Bytes
/
copyDataOnceADay().gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function copyDataOnceADay() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sourceSheet = ss.getSheetByName("test-fb");
var destinationSheet = ss.getSheetByName("data - by day");
// Get the data range from the source sheet (excluding header row)
var sourceDataRange = sourceSheet.getRange(2, 1, sourceSheet.getLastRow() - 1, 14);
var sourceDataValues = sourceDataRange.getValues();
// Filter out rows that have data in column A (to exclude any blank rows)
var filteredData = sourceDataValues.filter(function(row) {
return row[0] !== '';
});
// Get the range in the destination sheet where the data will be pasted
var destinationDataRange = destinationSheet.getRange(destinationSheet.getLastRow() + 1, 2, filteredData.length, 14);
// Clear the existing content in the destination range before pasting new data
destinationDataRange.clearContent();
// Paste the filtered data into the destination sheet
destinationDataRange.setValues(filteredData);
}