2016-10-04 6 views
0

での列の最後に空の行を検索します(分ごとに実行し、任意の値をフェッチします)Google Appsのスクリプト - 私は現在、このようなスクリプト持つスプレッドシート

// function 01 
    sheet2.getRange(sheet2.getLastRow() + 1, 1, 1, 6).setValues(values); 

    // function 02 
    sheet2.getRange(sheet2.getLastRow() + 1, 10, 1, 6).setValues(values); 

それは最後の行を見つけて設定次の行の値。両方とも別々の機能です。しかし、現在のところ、このようなものが出力されます。

電流出力:

// function 1 output here  // function 2 output here 
------------------------------------------------------------ 
| A |  B | C  ||   |   |  | 
------------------------------------------------------------ 
|  |   |   || D  | E | F | 
------------------------------------------------------------ 
|  |   |   || G  | H | I | 
------------------------------------------------------------ 
| J | K  | L  ||   |   |  | 
------------------------------------------------------------ 

よくない私はそれがこのように表示させたい:

期待された結果、私は明らかだ

------------------------------------------------------------ 
| A |  B | C  || D  | E | F | 
------------------------------------------------------------ 
| J |  K | L || G  | H | I | 
------------------------------------------------------------ 
|  |   |   ||   |   |  | 
------------------------------------------------------------ 

希望。

+1

これが役立ちます:http://stackoverflow.com/questions/6882104/faster-way-to-find-the-first-emptyrow –

答えて

1

非常にわずかMogsdadそれは、もちろん、可能性がスレッドに対応して新しいシートのため2014年11月27日にFaster way to find the first empty row

// Don's array approach - checks first column only 
// With added stopping condition & correct result. 
// From answer https://stackoverflow.com/a/9102463/1677912 
// Added the passing of myColumn which needs to be a column range 
// example use: var emptyRow = getFirstEmptyRowByColumnArray('B:B'); 
function getFirstEmptyRowByColumnArray(myColumn) { 
    var spr = SpreadsheetApp.getActiveSpreadsheet(); 
    var column = spr.getRange(myColumn); 
    var values = column.getValues(); // get all data in one call 
    var ct = 0; 
    while (values[ct] && values[ct][0] != "") { 
    ct++; 
    } 
    return (ct+1); 
} 

を供給溶液から列を渡すように変更され、以下の機能をお試しください必要に応じて列を渡して範囲を作成するように書かれています。

関連する問題