Matric vba array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Sub test()

'how to apply this matric in vba by replacing
Set Myarray_1 = Range("O11:O17")
Set Myarray_2 = Range("P11:P17")
Set Myarray_3 = Range("Q11:Q17")
Set Myarray_4 = Range("R11:R17")


Range("A1").Formula = "=SUM((" & Myarray_1.Address & "=O18)* " _
& "(" & Myarray_2.Address & "=P18)*(" _
& Myarray_3.Address & "=Q18)*(" & _
Myarray_4.Address & "=R18))"
End Sub
 
how to apply this matric in vba by replacing
O11:O17 by Myarray_1
p11:p17 by Myarray_2
q11:q17 by Myarray_3
r11:r17 by Myarray_4


=SUM((O11:O17=O18)*(P11:P17=P18)*(Q11:Q17=Q18)*(R11:R17=R18))


Thank you
 
notsure what you're asking. maybe this will give you some idea:

Sub test()
Dim arr As Variant
arr = Array(1, 2, 3, 4, 5)
Debug.Print Evaluate(Application.Sum(arr))
Range("a1:e1") = arr
End Sub

--


Gary


MyArray_1 and other tables do not have an address on the Excel sheet
the array is in memory,

if the condition is checked the table is written on the sheet


thank you





Joel a écrit :
 
MyArray_1 and other tables do not have an address on the Excel sheet
the array is in memory,

if the condition is checked the table is written on the sheet


thank you





Joel a écrit :
 
Once again, what do you expect O11:O17=O18 to return?

More specifically to the point,

=SUM((O11:O17=O18)*(P11:P17=P18)*(Q11:Q17=Q18)*(R11:R17=R18))

seems no different from

=SUM((O11=O18)*(P11=P18)*(Q11=Q18)*(R11=R18))

Is that how you intend it be used?

Alan Beban
 
Thank you for your reply



To know the number of Value between two Values
Array_1 do not have reference on the excel sheet of counting

what wants that's exactly, but it do not work.
the values of MyArray_1 are righteous man an example

Sub test_mat_array()
Array_1 = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
test_2 = Application.WorksheetFunction.Sum((Array_1 >= 1) * (Array_1 <= 5))
Cells(1, 1) = test_2

End Sub


Alan Beban a écrit :
 
Sorry. Syntax Array_1 >= 1 and Array_1 <= 5 I am not familiar with. I
can't see what you're intending.

Alan Beban
 

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

Back
Top