Answer the question
In order to leave comments, you need to log in
Script to replace cells if a condition is met?
Hello, tell me how to implement a script so that cells are replaced when the condition matches.
In a simple example,
there are 2 columns A and B.
In column A there are empty cells or with the text "Job"
it is necessary that "Job" be inserted into column B opposite in those cells where "Job" is written in the adjacent cell of column A.
it is desirable that it spread to the entire table (for example, columns AA AB can have the same values)
We need a script, not a formula, because I have a little different data and gave such an example.
upd: I made such a script, but it only works when editing, i.e. when I manually wrote "Work", then everything will work, how to make it look at the entire table and even where it already exists, then change it. And it is necessary that this does not happen automatically, but when I myself click (like triggers, as I understand it)
function onEdit() {
var sheetNameToWatch = "TEST";
var valueToWatch="Work";
varsheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getActiveCell();
var val=sheet.getActiveCell().getValue()
if (sheet.getName() == sheetNameToWatch && (val== valueToWatch )) {
var targetCell = sheet.getRange(range.getRow(), range.getColumn()- one);
targetCell.setValue("Job" );
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question