Home » excel » vb.net – Array based math within Excel formulas

vb.net – Array based math within Excel formulas

Posted by: admin May 14, 2020 Leave a comment


I’m working through an issue where I want to be able to total the number of correct selections a user has made. Each selection is weighted differently.

In excel I have a row of data points, each containing the correct answer, and below, each respondent’s data, such that their selection for the first question is in the same column as the key for the first question.

At the end of the row, I wish to include the number of points earned, so I would check across the row, if the respondents cell matches the provided cell, and if so, add in the appropriate number of points.

Unfortunately I cannot figure a way to do this using only a formula (no macros or custom functions as I am generating the excel files programically) and have resorted to a large string of “…+IF(C16=C8,1,0)+IF(D16=D8,5,0)+…”

Does anyone have any ideas?

How to&Answers:

Do you have the scores [weights] in the worksheet? If they are in row 9, for example try using SUMPRODUCT like this


If you want to put the scores directly in the formula you can do that like this


Assumes data up to column Z, adjust formula as required. If you might have blanks in the answer row you can avoid those being scored as correct by using this version: