Reputation: 47
My apps script code works when I use:
sheet.getRange("B2:D7").setValue(10);
But it does not work when I use:
sheet.getRange("DTstart:DTend").setValue(10);
Although,
var DTstart = B2;
var DTend = D7;
How do I circumvent this error? Is there a way to get the reference for a cell assigned to a variable? The value of DTstart and DTend changes throughout the code.
Upvotes: 1
Views: 1625
Reputation: 201428
DTstart
and DTend
.DTstart
and DTend
are B2
and D7
, respectively.If my understanding is correct, how about this modification?
B2
is used as a string, please modify to "B2"
DTstart
and DTend
are used as the variables, please modify to DTstart + ":" + DTend
instead of "DTstart:DTend"
.var DTstart = "B2"; // Modified
var DTend = "D7"; // Modified
sheet.getRange(DTstart + ":" + DTend).setValue(10); // Modified
10
is put to the cells of B2:D7
.If I misunderstood your question, I apologize.
Upvotes: 4