这是我拥有的查找函数的简短版本。如果您愿意,我有一个更复杂的,但请告诉我,我可以在另一个回复中发布。
//------------------Single Cell VLookup return var
/*
[129 Santa Clara BA 1234 abce W ]
[130 Los Feliz LA 5678 deff I ]
[131 Sand City BA 9112 ghig C ]
finderLookUP('Data','A:G',130,0,2) would return 'LA'
*/
function finderLookUP_(Sheet,Range,lookupItem,IndexOffset,IndexOffsetReturn) // finderLookUP(Ref Sheet, Ref Sheet Range, Current lookup Item, Ref Sheet Column for Current lookup Item , Ref Sheet Column for qualified Current lookup Item RETURN)
{
var data = SpreadsheetApp.getActive().getSheetByName(Sheet).getRange(Range).getValues(); //Syncs sheet by name and range into var
for(nn=0;nn<data.length;nn++)
{
var Sending = "";
if (data[nn][IndexOffset]==lookupItem)
{
var Sending = data[nn][IndexOffsetReturn];
return Sending;
}
}
if(isEmpty_(Sending)==true)
{
var Sending = "#N/A";
return Sending;
}
}