SumIf using two criteria

  • Thread starter Thread starter SA3214
  • Start date Start date
It is probably caused because you are comparing strings, and I didn't allow
for this. If both the A and B columns are text, use

TextBox11 = Evaluate("SUM(IF(((A1:A10)=""" & ComboBox1.Value & _
""")*((B1:B10)=""" & Textbox4.Text & """),D1:D10))")

If only column A is text, and B is a number, use

TextBox11 = Evaluate("SUM(IF(((A1:A10)=""" & ComboBox1.Value & _
""")*((B1:B10)=" & CDbl(Textbox4.Text) & "),D1:D10))")

Hope that this sorts it.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
You said:
I have found only evaluate works with SUMPRODUCT in VBA, and that works
okay
with your original as well.

I was expanding that statement to include all array entered formulas.

Application.SumProduct used two multiply, then sum the product of two
ranges as designed works fine - but that is not an array formula in the
sense of above.
 
Many many thanks - it works fine now

My apologies for the late acknowledgement ... I cut and pasted you piece of
code and it took me a while to figure out why it didn't work
(I am using ComboBox2 not ComboBox1)
I also moved the code from the spin events to the TextBox4.Change event.

I, and many thousands of others, owe you and your colleagues in this group a
great deal for the amount of time and effort you save us in solving these
vba problems. So much so that it often very tempting to ask before spending
even attempting to solve them for ourselves.

Heartfelt thanks and many regards

Jim Burton
(SA3214)
 
Thanks Jim, it is appreciated.

Regards

Bob


SA3214 @Eclipse.co.uk> said:
Many many thanks - it works fine now

My apologies for the late acknowledgement ... I cut and pasted you piece of
code and it took me a while to figure out why it didn't work
(I am using ComboBox2 not ComboBox1)
I also moved the code from the spin events to the TextBox4.Change event.

I, and many thousands of others, owe you and your colleagues in this group a
great deal for the amount of time and effort you save us in solving these
vba problems. So much so that it often very tempting to ask before spending
even attempting to solve them for ourselves.

Heartfelt thanks and many regards

Jim Burton
(SA3214)
 
Back
Top