AfterSelRangeChange 事件代码在计算求和、平均值时报的错,怎么修改?
代码:
Dim str As String = ""
Dim t As Table =CurrentTable
If Tables.contains(t.name)=False Then Return
With e.NewRange
Dim t1 As Integer=iif(t.Rows.Count-1<.TopRow,t.Rows.Count-1,.TopRow)
Dim t2 As Integer=iif(t.Cols.Count-1<.LeftCol,t.Cols.Count-1,.LeftCol)
Dim t3 As Integer=iif(t.Rows.Count-1<.BottomRow,t.Rows.Count-1,.BottomRow)
Dim t4 As Integer=iif(t.Cols.Count-1<.RightCol,t.Cols.Count-1,.RightCol)
If t.Aggregate(AggregateEnum.Sum, t1, t2, t3, t4) <> Nothing Then
Str = Str & "求和:" & t.Aggregate(AggregateEnum.Sum, t1, t2, t3, t4) & " "
Str = Str & "计数:" & t.Aggregate(AggregateEnum.Count, t1, t2, t3, t4) & " "
Str = Str & "平均值:" & t.Aggregate(AggregateEnum.Average, t1, t2, t3, t4)
Else
Str = Str & "计数:" & t.Aggregate(AggregateEnum.Count, t1, t2, t3, t4) & " "
End If
End With