Search for the Article

On change of cell, automatically update date and time.

To automatically add the current date to column E when a cell in column B is updated in Google Sheets, and to remove the date if the value in column B is removed, you can use a Google Apps Script. 

Here's how to do it: 
  1. Open your Google Sheet. 
  2. Go to Extensions > Apps Script. This will open the Apps Script editor. 
  3. Delete any code in the script editor and paste the following code:
	



<script type="text/javascript">
function onEdit(e) {
  var sheet = e.source.getActiveSheet();
  var range = e.range;
  
  // Check if the edited cell is in column B
  if (range.getColumn() == 2) {
    var row = range.getRow();
    var cell = sheet.getRange(row, 5); // Column E
    
    if (range.getValue() !== '') {
      // Set the current date in column E if column B is edited
      cell.setValue(new Date());
    } else {
      // Clear the date in column E if column B is cleared
      cell.clearContent();
    }
  }
}

<script>

If you want that a column name S.No too get automatically incremented, so here is the code
	

<script type="text/javascript">
function onEdit(e) {
  var sheet = e.source.getActiveSheet();
  var range = e.range;
  
  // Check if the edited cell is in column B
  if (range.getColumn() == 2) {
    var row = range.getRow();
    var dateCell = sheet.getRange(row, 5); // Column E
    var serialCell = sheet.getRange(row, 1); // Column A
    
    if (range.getValue() !== '') {
      // Set the current date in column E if column B is edited
      dateCell.setValue(new Date());
      
      // Set the serial number in column A if it is empty
      if (serialCell.getValue() === '') {
        // Find the last filled serial number and increment by 1
        var lastSerialNumber = sheet.getRange(row - 1, 1).getValue();
        serialCell.setValue(lastSerialNumber + 1);
      }
    } else {
      // Clear the date in column E if column B is cleared
      dateCell.clearContent();
      
      // Clear the serial number in column A if column B is cleared
      serialCell.clearContent();
    }
  }
}

<script>