I'm new with JavaScript and I'm working on a Spreadsheet trying to hide a column base on the cell content.
The idea is: when value 1 and value 2 are the same (the value of two different cells are identical), the column stays as unhidden. When is not identical, it hides. However, every time OnEdit, the columns hides regardless.
Also, I can't manage to make it unhide when the values are the same. Any ideas?
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName("Auto media planner"); // Enter sheet name
var cell1 = s.getRange('C7');
var cell2 = s.getRange('AX6');
var value1 = cell1.getValues();
var value2 = cell2.getValues();
var column = s.getRange("D1");
if (value1!=value2){
s.hideColumn(column);
}
if (value1==value2){
s.unhideColumn(column);
}