I am trying to put a formula based on the background color of a cell in row C.
It kinda works, but when I search and find a cell (say C7), my log finds it at C6. So when I use the putformula
, it gets in the wrong cell (the cell above it).
Then even when I find the right cell, how do I pass this info to the putformula
?
The code is a mixture of a lot of examples found on the Internet.
function testv1(){
var sourceSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("overzicht");
var lastSourceRow = sourceSheet.getLastRow();
var lastSourceCol = sourceSheet.getLastColumn();
var sourceRange = sourceSheet.getRange(1, 2, lastSourceRow, lastSourceCol); //6,2 / de 1e is row, de 2 is colum, (colum c)
var sourceData = sourceRange.getBackgrounds();
var activeRow = 2;
for (row in sourceData) {
if (sourceData[row][1] === '#efefef') {
Logger.log(row)
var formulaCell = sourceSheet.getRange([row + [0]],3,lastSourceRow,1)
formulaCell.setFormula('=IFERROR(SUM(filter(Transacties!$C:C;TEXT(Transacties!$A:A;\"yyyyMMMM\") = $D$3 & $C$3;regexmatch (Transacties!$F:F; A' + (row) + ')));\"Geen gegevens test test 5x\")');
}
}
}