0

i would like to see if theres a way that i can timestamp in column A in front of the row edit or a particaular number of column is edited or updated. Google Sheet I have heard appscript can be used but dont know how

Tanaike
  • 181,128
  • 11
  • 97
  • 165
Skilz Work
  • 15
  • 4

1 Answers1

0

I believe your goal is as follows.

  • When a cell is edited, you want to put the timestamp to column "A" of the same row of the edited cell.
  • You want to achieve this using Google Apps Script.

In this case, how about the following sample script? In this sample script, in order to detect the edit of cells, the simple trigger of OnEdit is used.

Sample script:

Please copy and paste the following script to the script editor of Spreadsheet. And, please set the sheet names you want to use, and save the script. When you use this script, please edit the cells. By this, the timestamp is put into column "A".

function onEdit(e) {
  const sheetNames = ["Sheet1"]; // Please set your sheet name.

  const { range } = e;
  const sheet = range.getSheet();
  if (!sheetNames.includes(sheet.getSheetName()) || range.columnStart == 1) return;
  sheet.getRange(range.rowStart, 1, range.rowEnd - range.rowStart + 1).setValue(new Date());
}

Note:

  • In this sample script, if you want to use the script with multiple sheets you want, please modify const sheetNames = ["Sheet1"]; like const sheetNames = ["Sheet1", "Sheet3",,,];.

Reference:

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • Hi @Tanaike thanks for quick reply this worked but what if timestamp column is not A but J or any other column. – Skilz Work Dec 28 '22 at 08:13
  • @Skilz Work Thank you fof replying. About `i @Tanaike thanks for quick reply this worked`, welcome. Thank you for letting me know. I'm glad your issue was resolved. If your question was solved, please push an accept button. Other people who have the same issue with you can also base your question as a question that can be solved. And I think that your issue and solution will be useful for them. If you don't find the button, feel free to tell me. https://stackoverflow.com/help/accepted-answer – Tanaike Dec 28 '22 at 08:36
  • @Skilz Work About your new question of `but what if timestamp column is not A but J or any other column.`, in this case, please modify `range.columnStart == 1` to `range.columnStart == 10` and modify `sheet.getRange(range.rowStart, 1, range.rowEnd - range.rowStart + 1).setValue(new Date());` to `sheet.getRange(range.rowStart, 10, range.rowEnd - range.rowStart + 1).setValue(new Date());`. – Tanaike Dec 28 '22 at 08:36
  • hi timestamps working perfect but when i try to **conditional format** it doesn't understand time. i am using this custom formula **=$A1=today()** and it is not highlighting. what to do – Skilz Work Dec 29 '22 at 12:48
  • @Skilz Work Thank you for replying. From `hi timestamps working perfect`, I understood that your 2nd question was resolved. About your 3rd issue of `but when i try to conditional format it doesn't understand time. i am using this custom formula =$A1=today() and it is not highlighting. what to do`, I would like to support you. – Tanaike Dec 29 '22 at 13:09
  • @Skilz Work In this case, I would like to recommend posting it as a new question. Because when your initial question is changed by a comment, other users who see your question are confused. By posting it as a new question, users including me can think of it. If you can cooperate to resolve your new issue, I'm glad. Can you cooperate to resolve your new question? – Tanaike Dec 29 '22 at 13:09
  • Hi thanks for the reply, issue is been resolved. – Skilz Work Dec 30 '22 at 13:06