'Google Sheets: Apps Script: Is there a way to automatically highlights and adjust the width of a column that matches this week's date?

I have a project roadmap tracker where each of the columns corresponds to the first date of the week. I have it automatically highlight the column if that date matches any date of the current week but the columns are so narrow that it's not easily legible. I want to expand the column that contains the a date that matches the current week when the sheet is opened.

I am not familiar with Google Apps script and have no idea how to approach this problem. Plus, hobbling together other example scripts have proven fruitless since I hardly know what these functions do with each other.

For highlighting the column of the current date/week, I'm using this conditional formatting formula that I would ideally prefer to be integrated into a script.

=AND(WEEKNUM(TODAY(),2)=WEEKNUM($2:$2,2),YEAR(TODAY())=YEAR($2:$2))

Where the formula looks for the date of each column in row 2 and checks if the date matches any date within this current week.

In short, I trying to write a script that:

  • On open
  • The script looks for the column that matches a date that exists within the current week
  • Automatically adjusts the column to be a specific width (like 200)
  • Automatically highlight that column a specific color (like pale red)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source