Multiplying to string arrays

S

smaruzzi

I have to arrays of test strings. Values could be Low, medium or High in both
arrays. I need to count how many pairs of High values appear when only High
has been selected for any row. In other words, when the same label has been
assigned in both column, that's a valid instance I wanna count.

here's an example:

Array1
Low
Medium
High
High

Array2
High
Medium
High
Medium

There is just one pair of Highs (3rd), and therefore the returned value
should be 1.

Thanks, Stefano
 
K

Ken Johnson

smaruzzi said:
I have to arrays of test strings. Values could be Low, medium or High in both
arrays. I need to count how many pairs of High values appear when only High
has been selected for any row. In other words, when the same label has been
assigned in both column, that's a valid instance I wanna count.

here's an example:

Array1
Low
Medium
High
High

Array2
High
Medium
High
Medium

There is just one pair of Highs (3rd), and therefore the returned value
should be 1.

Thanks, Stefano

Hi Stefano,

If your arrays are on a worksheet, say Array1 is A1:A4 and Array2 is
B1:B4, then use...

==SUMPRODUCT((A1:A4="High")*(B1:B4="High"))

If your arrays are VB arrays then use...

Dim lTally As Long
Dim I As Long
For I = 1 To UBound(Array1)
If Array1(I) = "High" And Array2(I) = "High" Then
Let lTally = lTally + 1
End If
Next
MsgBox lTally

I have assumed your arrays are one dimensional.

Ken Johnson
 
T

Teethless mama

=COUNT(IF((A2:A5="High")*(B2:B5="High"),1))

Array formula you have to commit Ctrl>Shift>Enter (not just enter)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top