我需要更改我的 Matching 函数,它匹配不同工作表上的两列并将匹配项返回到第三张工作表,以便它返回匹配的行
我一直在尝试,我的头在旋转,没有成功
谢谢
function RunMatch() {
// 0 is the LookIn sht column # to match on
// 1 is the LookWith sht column # to match on
MatchCols("LookInSheet","LookWithSheet","PostbackSheet",0,1)
}
function MatchCols(sShtName,tShtName,pbShtName,matchIn, matchWith){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var LookInSht = ss.getSheetByName(sShtName);
var LookWithSht = ss.getSheetByName(tShtName);
var PBSheet = ss.getSheetByName(pbShtName);
var LookIn = LookInSht.getDataRange().getValues();
var LookWith = LookWithSht.getDataRange().getValues();
var list = [];
for (i in LookIn){
var curName = LookIn[i][matchColIn];
var exists = true;
for (j in LookWith){
var curCheck = LookWith[j][matchColWith];
if (curCheck == curName){
exists = false;
break;
};
}; // end for j
list.push([exists ? "" : curName]);
} // end for i
PBSheet.getRange(1, PBSheet.getLastColumn() +1, list.length, 1).setValues(list);
}