I have created this google sheet to enter data for my work.
I have created the script below but the problem is when executed, it removes the formulas with the data in the cells. I want to move the data from the "Load Sheet" spreadsheet to "Archives" without removing formulas in the cells in "Load Sheet" spreadsheet.
//Scripts for Day 1
// confirmation pop-up
function confirmMove1() {
var ui = SpreadsheetApp.getUi();
var response = ui.alert("Are you sure you want to move day1 data to database?", ui.ButtonSet.YES_NO);
// Process the user's response.
if (response == ui.Button.YES) {
moveData1();
} else {}
}
// Copy data
function moveData1() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sourceSheet = ss.getSheetByName("load Sheet");
var sourceRange = sourceSheet.getRange("A8:X12");
var numRows = sourceRange.getNumRows();
var numCol = sourceRange.getNumColumns();
Logger.log(numRows);
var sourceValues = sourceRange.getValues();
Logger.log(sourceValues);
var targetSheet = ss.getSheetByName("Archives")
var range = targetSheet.getRange(targetSheet.getLastRow()+1, 1, numRows, numCol );
range.setValues(sourceValues);
sourceSheet.getRange("A8:X12").clearContent();
Browser.msgBox("Data has been successfully moved");
}
Here is the link to the google sheet. https://docs.google.com/spreadsheets/d/172jL9R88t6oMGQLqwQ4Rqa_Zgj31cBuTRiu8b96VmBo/edit?usp=sharing