Hi all, I am trying to create a macro that adds a new row to the bottom of a table and keeps the conditional formatting and functions of the row above it. My knowledge of these types of macros is VERY limited so please be patient when asking questions.
I currently have the following macro but this adds a row under A8 and I need it to add a row to the bottom of my spreadsheet. Any help would be greatly appreciated.
function AddNewRow() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('A8').activate();
spreadsheet.getActiveSheet().insertRowsAfter(spreadsheet.getActiveRange().getLastRow(), 1);
spreadsheet.getActiveRange().offset(spreadsheet.getActiveRange().getNumRows(), 0, 1, spreadsheet.getActiveRange().getNumColumns()).activate();
spreadsheet.getCurrentCell().setFormula('=INDIRECT("A" & ROW() - 1)+1');
spreadsheet.getRange('A10').activate();
};
Thanks in advance for your help.
I currently have the following macro but this adds a row under A8 and I need it to add a row to the bottom of my spreadsheet. Any help would be greatly appreciated.
function AddNewRow() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('A8').activate();
spreadsheet.getActiveSheet().insertRowsAfter(spreadsheet.getActiveRange().getLastRow(), 1);
spreadsheet.getActiveRange().offset(spreadsheet.getActiveRange().getNumRows(), 0, 1, spreadsheet.getActiveRange().getNumColumns()).activate();
spreadsheet.getCurrentCell().setFormula('=INDIRECT("A" & ROW() - 1)+1');
spreadsheet.getRange('A10').activate();
};
Thanks in advance for your help.