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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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
It seems to work great, thank you very much !
 
Upvote 0

Forum statistics

Threads
1,215,771
Messages
6,126,797
Members
449,337
Latest member
BBV123

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