2

Hi Guys I'm trying to tweak a formula. I need to change the hardcoded array to reference a cell range.

=SUM(COUNTIFS(B1:B196,{"*yes*","*no*"},C1:C196,"agree"))

However I would like it to look like:

=SUM(COUNTIFS(B1:B196,A1;A2,C1:C196,"agree"))

The wild cards are important as I need to do a countif or within stings of text.

Wouldn't mind a VBA soulution.

Any help would be appreciated.

4
  • have you tried INDIRECT() ? Commented Jul 29, 2015 at 23:38
  • @MacroMan no I havn't yet, how would I incorporate this? Commented Jul 29, 2015 at 23:56
  • 1
    I was going to explain, but the answer below using concatenation is much better tbh. Commented Jul 30, 2015 at 0:29
  • 1
    You have a good answer below but in the interest of tweaking the formula, are the wildcards really necessary? Even if they are, a *no* or even a *yes* can produce a lot of false positives. Commented Jul 30, 2015 at 1:32

1 Answer 1

4

Enter this as an array formula with ctrl-shift-enter:

=SUM(COUNTIFS(B1:B196,"*" & A1:A2 & "*",C1:C196,"agree"))
Sign up to request clarification or add additional context in comments.

2 Comments

Although it should be noted that using SUMPRODUCT rather than SUM would also suffice, and would not require array-entry.
Thanks doug and @xor I decided to use sumproduct just for convenience. But used your formula doug cheers guys really appreciate it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.