G2=SUMIF(A2:A10000,{"C","G","R","B"},B2:B10000) 这句话在VBA数组中可行,函数怎么不行了?请问函数怎么写法,或怎么改写?Sub t5()Dim arrarr = Application.SumIf(Range("a2:a10000"),Array("B","C","G","R"),Range("B2:B10000"))Range("G
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/28 21:05:02
G2=SUMIF(A2:A10000,{"C","G","R","B"},B2:B10000) 这句话在VBA数组中可行,函数怎么不行了?请问函数怎么写法,或怎么改写?Sub t5()Dim arrarr = Application.SumIf(Range("a2:a10000"),Array("B","C","G","R"),Range("B2:B10000"))Range("G
G2=SUMIF(A2:A10000,{"C","G","R","B"},B2:B10000) 这句话在VBA数组中可行,函数怎么不行了?
请问函数怎么写法,或怎么改写?
Sub t5()
Dim arr
arr = Application.SumIf(Range("a2:a10000"),Array("B","C","G","R"),Range("B2:B10000"))
Range("G2").Resize(4,1) = Application.Transpose(arr)
End Sub
G2=SUMIF(A2:A10000,{"C","G","R","B"},B2:B10000) 这句话在VBA数组中可行,函数怎么不行了?请问函数怎么写法,或怎么改写?Sub t5()Dim arrarr = Application.SumIf(Range("a2:a10000"),Array("B","C","G","R"),Range("B2:B10000"))Range("G
G2=SUMIF(A2:A10000,{"C","G","R","B"},B2:B10000)这个虽然不会错,但是有问题啊,它其实相当于G2=SUMIF(A2:A10000,"C",B2:B10000)
所以在宏里面应该是arr = Application.SumIf(Range("a2:a10000"),"C",Range("B2:B10000")).
如果你要统计=C或G或R或B的总和,应该用这个G2=SUM(SUMIF(A2:A10000,{"C","G","R","B"},B2:B10000))
对应宏里面是arr= Application.Sum(Application.SumIf(Range("a2:a10000"),Array("B","C","G","R"),Range("B2:B10000")))