以下公式需要很长时间才能运行。
= TRANSPOSE (
IFERROR (
INDEX (
FILTER(Students!B:B;
REGEXMATCH(Students!B:B; C50),
REGEXMATCH(Students!B:B; B50),
REGEXMATCH(Students!C:C; F50)
));"NO MATCH"
))
关于编码的任何建议都很棒,因为我知道编程很少。
由于 Ť
答案 0 :(得分:1)
这是一个自定义函数,可以替换您正在使用的公式。例如:
=listStudents(C50,B50,F50)
如果以这种方式使用,你仍然会不断重新计算,但它应该比正则表达式测试快得多。或者,可以从菜单项调用相同的函数,并用于填充工作表中的给定目标范围,从而避免自动重新计算。
代码:
/**
* Custom spreadsheet function to produce a list of names of
* students that match the given criteria.
*/
function listStudents( givenName, surname, employer ) {
var matches = []; // matching students will be placed in this array
var HEADERS = 1; // # rows of header info at top of sheet
var FULLNAME = 1; // Column containing full names (B)
var EMPLOYER = 2; // employers (C)
// Array filter function - returns true if conditions match
function test4match( row ) {
return ( row[FULLNAME].indexOf(givenName) !== -1 &&
row[FULLNAME].indexOf(surname) !== -1 &&
row[EMPLOYER].indexOf(employer) !== -1)
}
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Students');
var range = sheet.getDataRange();
var data = range.getValues().slice(HEADERS); // All data from sheet, without headers
var filteredData = data.filter(test4match); // Get matching rows
for (var i=0; i<filteredData.length; i++) {
matches.push(filteredData[i][FULLNAME]); // Then produce list of names
}
return [matches]; // Return a 2-d array, one row
}