Reputation: 30
Total noob here.
I have data that generates in cells A3:F3. I have recorded a Macro to copy those values to A8.
I have made a button. I have assignet that button to that Macro.
I can't figure out how to make that button copy the values (just the data) to the next available row.
Please help.
function CopyRow() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('A8').activate();
spreadsheet.getRange('A3:F3').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
};
Upvotes: 1
Views: 491
Reputation: 15318
Try
function CopyRow() {
var sh = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
var data = sh.getRange('A3:F3').getValues()
var lastRow = sh.getLastRow()+1
sh.getRange('A'+lastRow+':F'+lastRow).setValues(data)
};
Upvotes: 1