Pretty new to scripts.
I have a sheet with name information in columns A-C and dates from column D on.
I found a script that will hide all columns to the left of the column with the current date.
I would like to modify it to hide all columns to the right of column C, except for the column with the current date.
function onOpen(e) {
var sheet = e.source.getSheetByName('Sheet1'); // or .getSheets()[0]; to apply to the first sheet.
var width = sheet.getDataRange().getWidth();
var dates = sheet.getRange(1, 1, 1, width).getValues().valueOf();
var today = Date.now();
var minDiff = 1e9;
var imin = 0;
for (var i = 0; i < dates[0].length; i++) {
if (Math.abs(dates[0][i]-today) < minDiff) {
imin = i;
minDiff = Math.abs(dates[0][i]-today);
}
}
sheet.hideColumns(1, imin);
}