How to automatically replace a single value or several values when entered.
Important:
The Inputs and Outputs on the array must be in the same order
This only works on full-cell values and will not replace values in the middle of entries. That is, "Sio Bibble was here" will not become "4 was here."
Sheet (Make a copy from the File menu)
https://docs.google.com/spreadsheets/...
Script
function onEdit(e){
if (!e) throw "Do not run from editor, the function runs automatically whenever an edit is made"
autoReplaceValues(e);
}
function autoReplaceValues(e){
if (e.value != "Sio Bibble") return;
e.range.setValue(4);
}
function autoReplaceValues(e){
const values = ["Sio Bibble","Dud Bolt","Shu Mai"];
const index = values.indexOf(e.value);
if (index == -1) return;
const replacements = [4,8,7];
e.range.setValue(replacements[index]);
}
Connect with me:
• spencer.farris@gmail.com
• spencerfarris.me
• www.linkedin.com/in/spencer-farris/
• Twitter @FarrisSpencer
• Google Product Expert support.google.com/docs/profile/12305
Donate on Paypal: spencer.farris@gmail.com
On this page of the site you can watch the video online Automatically Replace Value When Entered with a duration of hours minute second in good quality, which was uploaded by the user Spencer Farris 10 January 2023, share the link with friends and acquaintances, this video has already been watched 3,196 times on youtube and it was liked by 30 viewers. Enjoy your viewing!