|
发表于 2024-10-17 08:59
来自手机
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 lss001 于 2024-10-20 06:55 编辑
Function CustomStat(ByVal Rng As Range, _
ByVal mode As Integer) As Variant
Dim r&, r1&, c$, c1$, n$, xVal&
Dim rn As Range, rg As Range
c = Split(Rng.Address, "$")(1) '数据列号
n = Application.Caller.Address '公式地址
c1 = Split(n, "$")(1) '公式列号
r = Split(n, "$")(2) * 1 '公式行号
r1 = Cells(r, c1).MergeArea.Count '合并个数
xVal = 0
For Each rg In Range(Cells(r, c), Cells(r + r1 - 1, c))
If mode = 1 Then '判断模式
xVal = xVal + rg.Value
Else
xVal = r1
End If
Next
CustomStat = xVal
End Function
|
评分
-
1
查看全部评分
-
|