Static timestamp in Google Sheets ?

Dosce

New Member
Joined
Feb 12, 2020
Messages
20
Office Version
  1. 365
Platform
  1. Windows
Hi,

I would like to automatically add timestamps in the A column every time any cell on a new row is filled (except for row 1 if possible).

I found this formula on wikihow :
/** @OnlyCurrentDoc */
function onEdit(e){
const sh = e.source.getActiveSheet();
sh.getRange ('A' + e.range.rowStart)
.setValue (new Date())
.setNumberFormat ('dd/MM/yyyy');
}

It does pretty much the job, I would just need it to be static, that means that when I come back to modify something on a row, it does not update the timestamp. And I would need to be able to manually modify it after its creation, like if I use a new row today, it will create the cell with 31/03/2023, but I would like to manually change it to let's say 28/03/2023, it does not allow me to do that for now. And if possible exclude the first row.

I hope it is clear, thank you !
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
JavaScript:
function onEdit(e) {
  const sh = e.source.getActiveSheet();
  var cell = e.range;
  var rngA = sh.getRange('A' + e.range.rowStart);
  if (cell.getColumn() != 1 && cell.getRow() > 1 && !rngA.getValue()) {
    rngA.setValue(new Date()).setNumberFormat('dd/MM/yyyy');
  }
}
 
Upvote 0
Solution

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top