I have a sheet with over 100,000 cells (will soon be 300,000+ cells) used as a Gantt Chart. Each cell has an IF formula which returns the letter X if the corresponding column's header (a date) is between the row's start and end date.
But what's slowing down the sheet dramatically is the conditional formatting behind it. The conditional formatting says if the cell's value is an X, then change the cell's background color and font color to green. If no X, the background color should be white. Since conditional formatting, as I understand it, is recalculated any time you make any edit to the sheet, the performance is drastically poor. So my thought is to remove the conditional formatting and add it as a Script, with a menu button that I can click any time I want it ran, as opposed to conditional formatting running every time I make an edit to the sheet.
Here is where I've gotten with the script, which doesn't work. I've tried a couple dozen variations of this, but can't find something that works - sometimes I get it to run with no error, sometimes there is an error. Is my context wrong somewhere?
function formatting() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet 1");
var range = ss.getRange("A1:A100");
var cellValue = range.getValues();
if (cellValue === 'X') {
ss.range.setBackgroundColor('#000000'); }
else {
cellValue.setBackgroundColor('#ffffff'); }
}