Last active
July 28, 2024 11:37
-
-
Save tueda/7b16b080dc8a683446b10d5416010592 to your computer and use it in GitHub Desktop.
Lambda function that compares specified cells, returning a score if they match. #excel #lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=LAMBDA(answerCell, correctAnswerCell, scoreCell, | |
IF(answerCell = "", | |
"", | |
IF(OR(scoreCell = "", scoreCell = "&"), | |
"", | |
LET(Z, LAMBDA(f, LET(g, LAMBDA(x, f(LAMBDA(v, LET(xx, x(x), xx(v))))), g(g))), | |
countRightAmpersands, Z(LAMBDA(countRightAmpersands, LAMBDA(cell, | |
LET(right, Offset(cell, 0, 1), | |
IF(right = "&", | |
countRightAmpersands(right) + 1, | |
0 | |
) | |
) | |
))), | |
n, countRightAmpersands(scoreCell), | |
answerRange, OFFSET(answerCell, 0, 0, 1, n + 1), | |
correctAnswerRange, OFFSET(correctAnswerCell, 0, 0, 1, n + 1), | |
IF(OR(answerCellRange = ""), | |
"", | |
IF(OR(correctAnswerCellRange = ""), | |
NA(), | |
IF(AND(answerCellRange = correctAnswerCellRange), | |
scoreCell, | |
0 | |
) | |
) | |
) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment