Google Sheets: Apply StikeThrough when ANY value entered into column

348 views Asked by At

I am making a sign-up sheet with available dates on the top, and names on the side. When a person puts their initials in one of the date columns, I'd like the date on top to change to StrikeThrough so that it is easily identified to others as being no longer available for selection. Any ideas on how to do this? So it needs to be something like: If ANY text appears anywhere in column E, Then E1:E3 changes to StrikeThrough.... Thanks!

I am using Google Sheets, PC, Windows 8. I am new here and if won't let me post images... Here is an idea of what I'm working with: https://dl.dropboxusercontent.com/u/41966437/OVERTIME%20SIGN%20UP%20%20%20Google%20Sheets.png

See my answers to the question below for more details. Thanks!

1

There are 1 answers

6
JPV On

Can you see if this works ? As a bonus I also made the line-though dissappear if the intitials are erased (and no other initials are in the same column).

function onEdit(e) {
var ss = e.source.getActiveSheet();
if (e.range.columnStart < 5 || e.range.rowStart < 3) return;
e.range.offset(-e.range.rowStart + 1, 0)
    .setFontLine(e.value ? "line-through" : "normal");

}

Note: the script will work on every sheet of the spreadsheet(workbook) if you need it to work on 1 sheet only, fill in the sheet name in the code below and use this instead of the previous:

function onEdit(e) {
var ss = e.source.getActiveSheet();
if (ss.getName() !== 'Sheet1' || e.range.columnStart < 5 || e.range.rowStart < 3) return;
e.range.offset(-e.range.rowStart + 1, 0)
    .setFontLine(e.value ? "line-through" : "normal");

}