Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google spreadsheet - Colour rows if Strikethrough

I have an online work spreadsheet with random cells marked as Strikethrough. So far there is no functions on Google spreadsheet to filter or isolate these cells which are marked as Strikethrough.

I came across with Google function isStrikethrough() but not sure if that can be used on app script.

What I am look as an outcome is to highlight the entire row if any cells in that row was marked Strikethrough.

enter image description here

This will be very helpful if someone can help me by creating an app script.

Thanks in advance :)

like image 888
Wish Avatar asked Mar 12 '23 08:03

Wish


1 Answers

This should do it.

function lineThrough(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];//first sheet
var lr= sheet.getLastRow()
var lc=sheet.getLastColumn()
var range = sheet.getRange(2,1,lr,lc);
var results = range.getFontLines();

 for (var i=0;i<lr;i++) {
   for (var j=0;j<lc;j++ ) {
    if(results[i][j]== "line-through"){
    var color=sheet.getRange(i+2, 1,1,lc).setBackground("yellow")
   }}
 }}     
like image 60
Ed Nelson Avatar answered Mar 21 '23 05:03

Ed Nelson