h行列校验

443 字
2 分钟
h行列校验

h行列校验#

Sub 选行校验(control As IRibbonControl) '行列校验-选行校验
i = 0
x = 0
n = 0
If Selection.Type = wdSelectionColumn Then
For Each Acell In Selection.Cells '求所选列合计数
If Acell.ColumnIndex > n Then
n = Acell.ColumnIndex
End If
Set CR1 = ActiveDocument.Range(Acell.Range.Start, Acell.Range.End - 1)
If IsNumeric(CR1.Text) Then
i = CR1.Text + i
End If
Next
For Each Acell In Selection.Cells '求所选列最后一行合计数
Set CR2 = ActiveDocument.Range(Acell.Range.Start, Acell.Range.End - 1)
If Acell.ColumnIndex = n Then
If IsNumeric(CR2.Text) Then
x = CR2.Text + x
End If
End If
Next
P = i - x
q = P - x
y = "列校验:" & Format(P, "Standard") & "-" & Format(x, "Standard") & "=" & Format(q, "Standard")
Else
y = "只支持选中表格范围!"
End If
Application.StatusBar = y
End Sub
Sub 选列校验(control As IRibbonControl) '行列校验-选列校验
i = 0
x = 0
n = 0
If Selection.Type = wdSelectionColumn Then
For Each Acell In Selection.Cells '求所选列合计数
If Acell.RowIndex > n Then
n = Acell.RowIndex
End If
Set CR1 = ActiveDocument.Range(Acell.Range.Start, Acell.Range.End - 1)
If IsNumeric(CR1.Text) Then
i = CR1.Text + i
End If
Next
For Each Acell In Selection.Cells '求所选列最后一行合计数
Set CR2 = ActiveDocument.Range(Acell.Range.Start, Acell.Range.End - 1)
If Acell.RowIndex = n Then
If IsNumeric(CR2.Text) Then
x = CR2.Text + x
End If
End If
Next
P = i - x
q = P - x
y = "列校验:" & Format(P, "Standard") & "-" & Format(x, "Standard") & "=" & Format(q, "Standard")
Else
y = "只支持选中表格范围!"
End If
Application.StatusBar = y
End Sub
Sub 区域求和(control As IRibbonControl) '行列校验-区域求和
i = 0
If Selection.Type = 5 Then
For Each Acell In Selection.Cells
Set CR = ActiveDocument.Range(Acell.Range.Start, Acell.Range.End - 1)
If IsNumeric(CR.Text) Then
i = CR.Text + i
End If
Next
i = "合计:" & Format(i, "#,##0.00;-#,##0.00; ")
ElseIf Selection.Type = 4 Then
For Each Acell In Selection.Cells
Set CR = ActiveDocument.Range(Acell.Range.Start, Acell.Range.End - 1)
If IsNumeric(CR.Text) Then
i = CR.Text + i
End If
Next
i = "合计:" & Format(i, "#,##0.00;-#,##0.00; ")
Else
i = "只支持表格内行或列求和!"
End If
Application.StatusBar = i
End Sub

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或打赏支持!

打赏

评论区

Profile Image of the Author
richfan
Hello, I'm richfan.
公告
欢迎来到我的博客!这是一则示例公告。
音乐
封面

音乐

暂未播放

0:000:00
暂无歌词
分类
标签
站点统计
文章
779
分类
8
标签
138
总字数
3,267,679
运行时长
0
最后活动
0 天前
站点信息
构建平台
Cloudflare Pages
博客版本
Firefly v6.13.5
文章许可
CC BY-NC-SA 4.0

文章目录