Reputation: 13
I created this function to change specific cell value, from "5.000,00 C" to "5.000,00":
But when I run the function the cell does not change.
I don't know what I'm doing wrong.
function myFunction() {
var FILE = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/");
var CONTENT = FILE.getSheetByName("r2--tests");
var A1 = CONTENT.getRange("G3").getValue()
var A1split = A1.split(" ");
A1.replace(A1, `${A1split[0]}`);
};
Upvotes: 0
Views: 40
Reputation: 428
You should assign the result of your replace to A1
, and then write it back to the Spreadsheet:
function myFunction() {
var FILE = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/");
var CONTENT = FILE.getSheetByName("r2--tests");
var A1 = CONTENT.getRange("G3").getValue()
var A1split = A1.split(" ");
A1 = A1.replace(A1, `${A1split[0]}`);
CONTENT.getRange("G3").setValue(A1);
};
Upvotes: 1
Reputation: 14423
You'd need to update the cell:
CONTENT.getRange("G3").setValue(A1.replace(A1, `${A1split[0]}`));
Upvotes: 1