Gpt says
function findMatchingRows() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet1 = ss.getSheetByName("Sheet1");
const sheet2 = ss.getSheetByName("Sheet2");
const data1 = sheet1.getDataRange().getValues(); // Full data from Sheet1
const data2 = sheet2.getDataRange().getValues(); // Rows to match from Sheet2
const results = []; // Store results: [Sheet2 row, Sheet1 match row]
for (let i = 0; i < data2.length; i++) {
const rowToMatch = data2[i];
const matchIndex = data1.findIndex(row =>
row.length === rowToMatch.length &&
row.every((val, idx) => val === rowToMatch[idx])
);
if (matchIndex !== -1) {
results.push([i + 1, matchIndex + 1]); // +1 for row numbers (1-based)
} else {
results.push([i + 1, "No Match"]);
}
}
Logger.log("Results: [Sheet2 row, Sheet1 matching row]");
Logger.log(results);