Embedding a if formular with a sum formular

Ronnie Jordan 0 Reputation points
2026-09-11T23:17:05.9733333+00:00

I want to embed a questions if B4 and B6 are empty then add all the correct cells in B6 thru Q6 compared to B4 thru Q4 otherwise show a 0

Microsoft 365 and Office | Excel | For home | Windows
0 comments No comments

1 answer

Sort by: Newest
  1. AI answer

    2026-09-11T23:17:18.6066667+00:00

    Use an IF formula to return 0 when the key cells are empty, and otherwise count the matches across the two ranges.

    If the goal is:

    • if B4 and B6 are empty, return 0
    • otherwise compare B6:Q6 to B4:Q4 and count the matching cells

    use:

    =IF(AND(B4="",B6=""),0,SUM(IF(B4:Q4=B6:Q6,1,0)))
    

    How it works:

    • AND(B4="",B6="") checks whether both cells are empty.
    • If both are empty, the formula returns 0.
    • IF(B4:Q4=B6:Q6,1,0) creates an array of 1s and 0s based on whether each pair of cells matches.
    • SUM(...) adds those results to give the total number of matches.

    If the requirement is to return 0 when either B4 or B6 is empty, use this instead:

    =IF(OR(B4="",B6=""),0,SUM(IF(B4:Q4=B6:Q6,1,0)))
    

    If Excel requires array entry for this formula, enter it with Ctrl+Shift+Enter.


    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.