I have a formula in column Y. Because of the nature of the formula, I want to copy the contents of the data in column Y when the formula gets calculated, into column Z (onEdit). The code I have so far does not copy any data into the adjacent cell and does nothing when executed:
function onEdit(CopyCourse){
if(CopyCourse.source.getActiveSheet().getName() == "Sheet1" ) {
var actcell = CopyCourse.source.getActiveCell();
var col = CopyCourse.source.getActiveCell().getColumn();
if(col == 25) {
var calcourse = CopyCourse.range.offset(0,1);
//if(calcourse.getValue() == "" && CopyCourse.value != "No") {
var course = CopyCourse.actcell.getValue();
calcourse.setValue(course);
//}
}
}
}
Newer attempt, again no action on the spreadsheet:
function onEdit(e){
var r = e.range();
var o = e.oldValue();
var n = e.range().offset(0,1);
n.setValue(o);
}
This is what I came up with. It works if I enter the formula in each individual cell, however, if I do a copy down, it only copies over the first cell.
function onEdit(e){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var row = e.source.getActiveCell().getRow();
var col = e.source.getActiveCell().getColumn();
if(col == 25){
var course = e.source.getActiveCell().getValue();
var cell = sheet.getRange(row,col+1);
cell.setValue(course);
}
}
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.