同学,计算有内容的单元格用COUNTA函数
如图:
H2输入 =COUNTA(A2:G2)
即可。
列也一样
请参考以下公式,列请自己指定
非空单元格计数公式 =countif(列,"<>")
=countif(列,"<>"), 包含 有公式但是显示为空白的单元格 以及非空的数值或文体单元格
=COUNTIF(A:A,"<>")判断A列中不为空的单元格数量
Sub Test()
Dim strName1, strName2, strName3 As String
Dim data As String
Dim temp As String
Dim i, p, q As Integer
Dim m, n As Integer
Dim l As Double
p = 0
q = 0
For i = 1 To 65535
strName1 = "A" + Trim(Str(i))
data = Range(strName1).Value
data = Trim(data)
If (data = "") Then
p = p + 1
Else
q = q + 1
End If
Next
MsgBox ("有内容行数" + Str(q))
End Sub