Re: [算表] VBA陣列運算問題(SUMIF)

作者: nazomegami (深呼吸~)   2016-03-01 20:23:00
小弟實在不才,上網找了一些跟evaluate相關的說明,還是不清楚""、join、&的用法...
繼sumif後,我嘗試要做countif,不過得到到ary(i)陣列值皆是0。
請問版上大大我要如何修改? 謝謝!!
Sub test()
Dim a, b
Dim d, i&
Dim ary(10)
a = Array("A", "B", "A", "B", "B", "C", "B", "C", "D", "B")
b = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
d = UBound(a)
For i = 0 To d
ary(i) = Evaluate("count({""" & Join(a, """,""") & """}=""" & a(i) _
& """)")
Next
End Sub
作者: soyoso (我是耀宗)   2016-03-02 00:11:00
evaluate內改為"count(if({""" & Join(a, """,""") & """}=""" & a(i) & """,1))"https://i.imgur.com/mKws7KW.png
作者: nazomegami (深呼吸~)   2016-03-02 12:19:00
測試沒問題,謝謝你!

Links booklink

Contact Us: admin [ a t ] ucptt.com