SUB Rectangle 1_Click ()
DIM X as integer
For x = 1 to 20
Sheets ("sheet1"). Cells (x, 1) = x
NEXT
End Sub
This is a negative value of A1-A20, A1 = 1, A2 = 2 .... A20 = 20
-------------------------------------------------- -------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------
SUB Rectangle 1_Click ()
Range ("a21"). Value = Application.WorksheetFunction.Sum (Range ("A1: A20"))))
End Sub
This is a negative value for A21, let A21 are A1-A20 and
-------------------------------------------------- -------------------------------------------------- -------------------------
SUB Rectangle 1_Click ()
DIM I as integer
For i = 1 to 20
Sheets ("Sheet1"). Cells (i, 1) = i
NEXT
WITH Application.WorksheetFunction
Range ("a21"). Value =
. Sum (Range ("A1: A20")) Note that there is a point in front of SUM.
Range ("a22"). Value =
. Above ("A1: A20")))
End welhend Sub
Application.WorksheetFunction.
Average is averaged. Application.WorksheetFunction is a scope, I understand SUM, Average Average is a static method of static classes.
-------------------------------------------------- -------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------
SUB Rectangle 1_ Click () DIM I as Integer for i = 4 to 36 Sheets ("Sheet1"). Cells (i, 4) = i Next Range ("D37"). Value = Application.WorksheetFunction.Sum (Range ("D4: D36")) Range ("B1"). Value = Application.WorksheetFunction.counta (Range ("A1: A40000")) End Subcounta is a non-empty cell number, RANGE ("A1: A40000") Indicates that the law is not good, if it is a column A
So best
Range ("b1"). Value = .counta (Column (1)) Range ("B2"). Value = .counta (Range ("A: A")))