VBA Count occurrence of an element in a multi-dimensional array, how?
VBA Count occurrence of an element in a multi-dimensional array, how? I have defined a multi-dimensional array using range in vba, for example Dim Arr() as Variant Arr = Range("A1:F5") This resulted the a 5x6 array Arr(1,1) to Arr(5,6) I want to count the occurrence of a string, say "ABC" in Arr(5) (i.e. Row 5) only. The following code can find the count of "ABC" in the all of the array For Each x in Arr if x = "ABC" then Cnt = Cnt + 1 Next But if only want to count dimension 5, Arr(5) return an error. Arr is Arr(1 to 5, 1 to 6). Which 5 are you talking about? – Jeeped Jun 30 at 9:22 2 Answers 2 Sub FindABC() Dim Arr(), cnt, x Const ROW_NUM = 5 Arr = Range("A1:F5") For x = 1 To UBound(A...