I’m just not getting this. I simply want to copy the value from one cell to another in the same row. Simple right? Well, it fills every cell (to the right) with the value instead of just one cell. I’ve racked my brain over this and I guess I’m just not understanding something.
/* This gets the entire sheet (range) doesn't it? */
var range = SpreadsheetApp.getActiveSheet().getDataRange();
var rowRange ;
var status ;
var notes ;
var i=981;
var theEnd=979;
for (; i > theEnd; i--) {
rowRange = range.offset(i, 0, 1); // Doesn't this specify one row (range) ?
status = rowRange.offset(0, statusColumnOffset).getValue(); // one cell, right?
notes = rowRange.offset(0, notesColumnOffset).getValue();
/* it gets the correct value for notes */
if (notes == "No Number") {
// copy notes cell to status cell
/* I've tried both this (first attempt): */
//rowRange.offset(0, statusColumnOffset).setValue("No Number");
/* and this (second attempt): */
statusCell = rowRange.offset(0, statusColumnOffset);
statusCell.setValue("No Number");
/* both give the same results */
}
Now I’m puzzled why my first attempt with “rowRange.offset(0, statusColumnOffset).setValue(“No Number”);” did what it did. It gets the value of one cell just fine. So why in the world does the identical code (other than setting instead of getting) result in a full row being set with the value in each cell?? I’m just as puzzled as to why my second attempt gives the same (wrong) results. What is it I’m not understanding?
Thank you
Yes it does, a range that is as wide as the number of populated columns in the sheet. So this:
will be just as wide. I believe you would need to use:
https://developers.google.com/apps-script/class_range#offset