Skip to content

Instantly share code, notes, and snippets.

@ochilab
Created October 18, 2019 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochilab/c26ba8829b5229fe690cdb3fd723eb78 to your computer and use it in GitHub Desktop.
Save ochilab/c26ba8829b5229fe690cdb3fd723eb78 to your computer and use it in GitHub Desktop.
Google Sheetのセルを線形探索する
var keyword ="hogehoge";
var range = targetSheet.getRange(1, 2, targetNum); //2列目のデータを範囲とする
var target = range.getDisplayValues();//列のデータを取得
//なぜかtargetが文字列配列とならないので、下記の処理で文字列配列に変換
var targetList = target.toString().split(",");
var pos = targetList.indexOf(keyword); //ここで一発検索
if(pos==-1){
// 検索失敗
}else{
//検索成功
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment