SubSumCount()
DimrowcountAsInteger
DimaCountAsInteger
rowcount=ActiveSheet.[a90000].End(xlUp).Row
Fori=1Torowcount
aCount=aCount+Range("A"&i).Value
Next
EndSub
如果是以行求和,以第壹行求和為例,代碼如下
SubSumCount()
DimcolumncountAsInteger
DimaCountAsInteger
columncount=ActiveSheet.[IV1].End(xlToLeft).Column
Fori=1Tocolumncount
aCount=aCount+Cells(1,i).Value
Next
EndSub
如果是不規則的內容求和,可以先將數據存入數組中,在從數組中實現求和,以單元格A1,B2,C3為例,代碼如下:
SubSumCount()
DimarrData(2)
DimaCountAsInteger
Fori=0ToUBound(arrData)
arrData(i)=Cells(i+1,i+1).Value
aCount=aCount+arrData(i)
Next
EndSub。