I would like to create a custom function to count the number of strikethrough text. Would it be possible to create a script to perform this operation?
For the moment, I managed to create a script that counts the cell number with the strikethrough text, but I have to modify my script each time for a different range, and I can not create a custom function that count the number of cells that have the text strikethrough.
Here is my script:
The result is in the L20 and the control in the script
// Count the number of cells that are barred
function fontLine() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var plage = "E4:E11"
var range = sheet.getRange(plage);
var x = 0;
for (var i = 1; i <= range.getNumRows(); i++) {
for (var j = 1; j <= range.getNumColumns(); j++) {
var cell = range.getCell(i, j);
if (cell.getFontLine() === 'line-through')
x++;
}
}
sheet.getRange("L20").setValue(x);
return x;
}