3

I would like Google Sheets to insert a new column between columns A and B at the start of each new day with that day's date in cell B1. Is there a function or script that would make this possible?

1 Answer 1

1

Use this script, adjusting the sheet name and date format if necessary. It should be entered in Script Editor, found in Tools menu. After saving the script file, go to Resources > Current project's triggers, and create a trigger to run the function newColumn daily, at your preferred time.

function newColumn() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheetByName('Sheet1'); sheet.insertColumnAfter(1); sheet.getRange("B1").setValue(new Date()).setNumberFormat('M/d/yyyy'); } 
2
  • Thank you! I added this to make the column width smaller as the default cell size was really large due to my Column 1 having lots of text. sheet.autoResizeColumn(2); Commented Jul 3, 2016 at 0:54
  • Would it be possible to modify it so that it adds a column right after the last existing column ? Thank you. Commented Jan 28, 2020 at 8:53

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.