- Countup step = 1
- Countup step = 2 or more
- Countdown step = 1
For with Step 1
function forTest1() {var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
for (var i = 1; i < 5; i++) {
var range = sheet.getRange(8,i);
var data = range.setValue(i);
}
}
For with Step 2
function forTest2() {var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// step = 2 (or more)
for (var i = 1; i < 10; i=i+2) {
var range = sheet.getRange(9,i);
var data = range.setValue(i);
}
}
For with countdown loop
function forTest3() {var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
for (var i = 10; i > 3; i=i-1) {
var range = sheet.getRange(11,i);
var data = range.setValue(i);
}
}
Žádné komentáře:
Okomentovat