I need a script that autofills a cell with the values of a cell in the same row, but in a different (but fixed) column.
I have tried this script, but I can't get it to write the Value of anything but the cell itself.
function onEdit(event) {
var sheet = event.source.getActiveSheet();
var range = event.source.getActiveRange();
if (sheet.getSheetName() == "Tweet" && range.getColumn() == 2 && range.getValue().toString().trim() !== "" && range.getValue().indexOf("http:") != 0) {
range.setValue("http://test.com/" + range.getValue());
}
Try this:
function onEdit(event) {
var sheet = event.source.getActiveSheet();
var range = event.source.getActiveRange();
var fixed_column = 6; //Substitute this to your fixed column number.
if (sheet.getSheetName() == "Tweet" && range.getColumn() == 2 && range.getValue().toString().trim() !== "" && range.getValue().indexOf("http:") != 0) {
range.setValue("http://test.com/" + sheet.getRange(range.getRow(),fixed_column).getValue());
}
}
Just substitute the number of your fixed column.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.