function copyDataWithinWorkbook() {
var sourceSheetName = "Dashbord"; // Replace with the name of the source sheet
var targetSheetName = "Data"; // Replace with the name of the target sheet
var insertRow = 27; // Specify the row before which the data should be inserted
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sourceSheet = spreadsheet.getSheetByName(sourceSheetName);
var targetSheet = spreadsheet.getSheetByName(targetSheetName);
if (!sourceSheet) {
Logger.log("Source sheet not found: " + sourceSheetName);
return;
}
if (!targetSheet) {
Logger.log("Target sheet not found: " + targetSheetName);
return;
}
var sourceRange = sourceSheet.getRange("A25:G52");
var targetRange = targetSheet.getRange(insertRow, 1, sourceRange.getNumRows(), sourceRange.getNumColumns());
targetSheet.insertRowsBefore(insertRow, sourceRange.getNumRows());
var sourceValues = sourceRange.getValues();
targetRange.setValues(sourceValues);
Logger.log("Data copied successfully from " + sourceSheetName + " to " + targetSheetName);
}
No comments:
Post a Comment
THANKS FOR YOUR SUPPORT