For some reason, the solution described here doesn't work for me. Here is my whole code that should replace the 'PPP' with 'nothing'
function tests() {
// I need to replace more occurrences of different strings, so this is just an example..
var ui = SpreadsheetApp.getUi();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var range = ss.getRange("F22:F24").getValues();
var test = [];
// this is a loop, to go through multiple cells that may contain the text, that needs to be replaced.
for (var i = 0; i < range.length; i++) {
var le = range.length;
var stri = range[i].toString().replace("PPP", "");
test[i] = stri;
}
//range.setValues(test);
ss.getRange("F22:F24").setValues(test);
var msg = ui.alert("Replaced?");
return msg;
I tried a couple of things with setValue
, setValues
and simply with =
and nothing... With the code above I get this error
Cannot convert Array to Object[][]
There must be a simple way to replace strings with App Script, considering that in Google Spreadsheets you can simply CTRL + H
and replace any text with any text you want...
(I know I must learn Javascript, but time is now very tight...)