を使用して空にしていないGoogleスプレッドシートから行を選択します。特定の列の値が、私はデータセットを持っているし、ここでそのためのリンクであるGoogle Appsのスクリプトに
https://docs.google.com/spreadsheets/d/1QgR7WC2bj2_AW7yTDnjEXDrYKGo1GR_w_ea-8PtRwm4/edit?usp=sharing
それでは、私が欲しいのは、あります列Aの任意のセルに日付(空ではない)がある場合は、行全体をフェッチします。未定義の0.0 『
私もあるスタックオーバーフロー内の1つのスクリプトを得た:
function copynotempty(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = SpreadsheetApp.setActiveSheet(ss.getSheets()[0])
var col = 0 ; // choose the column you want to check: 0 = col A, 1= col B ...
var range = sh.getDataRange();
var values=range.getValues();// data is a 2D array, index0 = col A
var formulas=range.getFormulas();// data is a 2D array, index0 = col A
var target=new Array();// this is a new array to collect data
for(n=0;n<range.getHeight();++n){
if (values[n][col]!=''){ ;
for (cc=0;cc<range.getWidth();++cc){
if (values[n][cc]!=''){target[n][cc]=values[n][cc]}
// if the cell has a formula copy it or else copy the value, do that for the whole row
// (this also defines and apply the 'priority' you mentioned in your question, I wasn't sure if it should apply to the whole row or only on column B)
}
}
}
if(target.length>0){// if there is something to copy
var sh2=SpreadsheetApp.setActiveSheet(ss.getSheets()[1]); //second sheet of your spreadsheet
sh2.getRange(1,1,target.length,target[0].length).setValues();// paste the selected values in the 2cond sheet
}
}
をしかし、私は私が共有しているデータセットにこれを使用している場合、私はこのエラー」プロパティを設定できませんTypeError例外』を取得しています(12行目、 "コード") "を入力してください。
ありがとうございます。
スクリプトに感謝します。しかし、例えば私がsheet1にデータセットを持っていて、私が "= copynotempty(Sheet1!A:E)"と書いてスクリプトを使用しようとした場合、それは空であるsheet2にエラーを投げます。 "あなたはsetNumberFormat 4行目)。 "なぜこのようなことが起こっているのか分かりませんか? –
サンプルスクリプトを更新しました。結果はsheet2にインポートされます。 – Tanaike
ありがとうございます。受け入れボタンをこの質問にプッシュできますか? – Tanaike