Home > OS >  Google Sheets Script - onEdit(e) - Check if cell is a value
Google Sheets Script - onEdit(e) - Check if cell is a value

Time:10-04

How can I make onEdit to constantly check if a specific cell is a specific value?

I would like to get an alert when a cell, which is a formula produces an error. It is an importrange and sometimes it gets 'Heavy Usage' error. So I would like onEdit to constantly check if it is not an error.

At the moment, the cell will output "Formula Works" if it detects no error or will just output the error. Whenever cell changes from "Formula Works" to the error I would like to get the alert [SpreadsheetApp.getUi().alert("Error");].

Basically, OnEdit should be constantly checking it is "formula works" based on my every change.

This script i made did not work.

  var range1 = e.range;
  var spreadSheet = e.source;
  var sheetName = spreadSheet.getActiveSheet().getName();
  var column = range1.getColumn();
  var row = range1.getRow();


  if( s.getName() == "Settings" ){
    if( range1.getRange(B6) != "Formula Works" ) {
      SpreadsheetApp.getUi().alert("Error");
    }

Thanks!

CodePudding user response:

Something like this:

function onEdit(e) {
  if(e.source.getRange("SheetName!A1Notataion").getValue() == "Error Value") {
    SpreadsheetApp.getUi().alert("There is an error"):
  }
}
  • Related