I have a table consisting of several sheets. The table should be processed daily by several users at the same time. The main editing is done in Sheet1. Sheet2 consists only of a query and formulas.
Example Sheet 1:
- Sheet 1 consists of 2500 rows and 17 columns.
Starting with row 12 (row 11 is the header row. The rows above contain formula references), columns A, B are to be filled in by the user. The columns C-H contain various formulas (e.g. GoogleFinance queries). The columns G-M must be filled in again by the user. Finally, there are formulas in the columns N-Q again.
Goal: Automatic expansion / deletion of formulas in columns C-H and N-Q, depending on whether content has been added / removed in columns A and B. The deletion process should be performed line by line to also delete remaining user content in the columns G-M.
The sheet schould also be sortable.
Example Sheet 2:
- Sheet 2 consists of 1500 rows and 11 columns.
Starting with line 9 (line 9 is also the header line. The rows above contain formula references), the columns A-I are filled with results of a query (which is located in cell A9). The query obtains certain contents from Sheet 1 and is dynamic. The columns J-K contain formulas.
Goal: Automatically extend / delete the formulas in the columns J-K, depending on whether content was added / removed in the columns A-I (by the query).
For extending, deleting and sorting I used the code examples below.
Unfortunately, the codes shown do not meet the requirements described in the constellation. I would therefore be very grateful for a better solution.
function fillDownFormulaTD(){
Sheet = "sheet1";
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(Sheet);
var lr = ss.getLastRow();
var Rng1 = ss.getRange(1, 2, lr-1);
ss.getRange("").setFormula('');
ss.getRange("").copyTo(Rng1);
}
function removeEmptyRows(){
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Ticker-Datenbank');
var maxRows = sheet.getMaxRows();
var lastRow = sheet.getLastRow();
sheet.deleteRows(lastRow+1, maxRows-lastRow-20);
}
function Sortieren(){
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('A11:Q11')
var currentCell = spreadsheet.getCurrentCell();
spreadsheet.getSelection().getNextDataRange(SpreadsheetApp.Direction.DOWN).activate();
currentCell.activateAsCurrentCell();
spreadsheet.getActiveRange().sort({column: 3, ascending: true});
spreadsheet.getRange('A11').activate();
}
onEdit
trigger. It tells you the columnStart, columnEnd, rowStart and rowEnd. Why not use these coordinates to loop though several rows and test cells for add/deleted data? – Tedinoz