答:Sum函數(shù)可以在工作表中求,同樣也可以對(duì)VBA數(shù)組求和,如:
Sub t2() arr = Array(1, 35, 4, 13) MsgBox Application.Sum(arr) '對(duì)數(shù)組進(jìn)行求和 End Sub
2、Count和Counta
Count和Counta可以統(tǒng)計(jì)數(shù)組中數(shù)字的個(gè)數(shù)和數(shù)字+文本的個(gè)數(shù)。
Sub t3() arr = Array(1, 35, "a", 4, 13, "b") MsgBox Application.Count(arr) '返回?cái)?shù)字的個(gè)數(shù)4 MsgBox Application.CountA(arr) ‘返回?cái)?shù)組文本和數(shù)字的總個(gè)數(shù) End Sub
|