Function CheckCellIdentity(ColumnNumber As Integer, ColumnLBound As Integer, ColumnUBound As Integer) As Boolean
CheckCellIdentity = False
On Error GoTo iExit
If ColumnNumber >= ColumnLBound And ColumnNumber <= ColumnUBound Then
CheckCellIdentity = True
End If
iExit:
End Function
Function YSUM(xRng As Cells)
'本代码的作用是纵向求和,自动将选定区域中的最后一行数字转化为其相反数与选定区域的其他数据相加,如果结果为0说明Casting 正确,如果结果不为0,说明Casting有问题
On Error Resume Next
Dim xCell As Range
Dim yRng As Range
Dim iCell As Cell
Dim iSum() As Variant
Dim xChoice As Integer
ReDim iSum(xRng.Item(xRng.Count).ColumnIndex - xRng.Item(1).ColumnIndex + 1)
For i = 0 To xRng.Item(xRng.Count).ColumnIndex - xRng.Item(1).ColumnIndex
iSum(i) = 0
Next i
Set yRng = ActiveDocument.Range(Start:=xRng.Item(1).Range.Start, End:=xRng.Item(1).Range.Start)
yRng.Select
For Each iCell In xRng
Set xCell = ActiveDocument.Range(Start:=iCell.Range.Start, End:=iCell.Range.End - 1)
If CheckCellIdentity(ColumnNumber:=iCell.ColumnIndex, ColumnLBound:=xRng.Item(1).ColumnIndex, ColumnUBound:=xRng.Item(xRng.Count).ColumnIndex) = True Then
Set yRng = ActiveDocument.Range(Start