そして、これがあなたが試すことができる「スクリプトソリューション」です。多くの可能なアプローチがあります、これはそれらの1つです...
function testfindRow(){ ;// this function only to test the other one by giving it a parameter and using its result.
var ss = SpreadsheetApp.getActiveSpreadsheet();
var otherSheet=ss.getSheets()[1];// assuming there is a second sheet to copy to
var datatocopy=findRow('Hello');
Logger.log(datatocopy)
if (datatocopy!=-1){
otherSheet.getRange(otherSheet.getLastRow()+1,1,1,datatocopy[0].length).setValues(datatocopy);
}
}
//
function findRow(item) { ;// the actual search function
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet=ss.getSheets()[0];
var values = sheet.getDataRange().getValues();
for(cc =0; cc < values.length; ++cc) {
if(values[cc].toString().match(item)==item){break};// here you can eventually use string modifiers like toLowerCase() to allow for wider search criteria
}
Logger.log(cc);// the array index in which the result was found, cc+1 is the Row index
if (cc==values.length){return -1}
var resultArray=sheet.getRange(cc+1,1,1,values[cc].length).getValues()
return resultArray ;// the returned value is a 2 dimensions array to use with setValues()
}
あなたのコメントに続いて、これはアイテムを含むすべての行を返すバージョンです。エラートラップも変更する必要がありましたが、結局のところ、全体が非常に単純です。
function testfindRow(){ ;// this function only to test the other one by giving it a parameter and using its result.
var ss = SpreadsheetApp.getActiveSpreadsheet();
var otherSheet=ss.getSheets()[1];// assuming there is a second sheet to copy to
var datatocopy=findRow('Hello');
if (datatocopy.length>0){
otherSheet.getRange(otherSheet.getLastRow()+1,1,datatocopy.length,datatocopy[0].length).setValues(datatocopy);
}
}
//
function findRow(item) { ;// the actual search function
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet=ss.getSheets()[0];
var resultArray=new Array();
var values = sheet.getDataRange().getValues();
for(cc =0; cc < values.length; ++cc) {
if(values[cc].toString().match(item)==item){// here you can eventually use string modifiers like toLowerCase() to allow for wider search criteria
// or like this to search only in column D // if(values[cc][3].toString().match(item)==item){
resultArray.push(values[cc]);
};
}
Logger.log(resultArray);// the array of Rows in which the item was found,
return resultArray ;// the returned value is a 2 dimensions array to use with setValues()
}