我有一个切换单元格,可以在我的工作簿中的多个工作表中提供计算。目标是,每当更改此切换单元格时,工作簿将重新计算并提供更新编号。
我已开启手动计算。
以下是我尝试过的方法(请注意代码在表格中)
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Cells(3, 4)) Is Nothing Then
Application.Calculate
End If
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Cells(3, 4)) Is Nothing Then
Application.CalculateFull
End If
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Cells(3, 4)) Is Nothing Then
Application.CalculateFullRebuild
End If
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Cells(3, 4)) Is Nothing Then
range("DI:DI").calculate
'to calculate the specific range which drives the updated numbers
End If
这些方法都不起作用。唯一的方法是保存工作簿,并计算所有内容。
有什么想法吗?
----------------------------- EDIT ----------------- ------------
只有到目前为止有效的解决方案,强制计算驱动最终结果的所有单元格。希望有一个更优雅的解决方案。总运行时间~3秒\
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Cells(3, 4)) Is Nothing Then
Worksheets("Dashboard").Range("af3").Calculate
Worksheets("Base").Range("R1:R50000").Calculate
Worksheets("Control").Range("R1:R50000").Calculate
Worksheets("Base").Range("DI1:DI50000").Calculate
Worksheets("Control").Range("DI1:DI50000").Calculate
Worksheets("Dashboard").Range("W10:W5000").Calculate
Worksheets("Dashboard").Range("L10:L5000").Calculate
Worksheets("Dashboard").Range("Y10:Aa5000").Calculate
Worksheets("Dashboard").Range("B2:B7").Calculate
end if
答案 0 :(得分:0)
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Cells(3, 4)) Is Nothing Then
Worksheets("Dashboard").Range("af3").Calculate
Worksheets("Base").Range("R1:R50000").Calculate
Worksheets("Control").Range("R1:R50000").Calculate
Worksheets("Base").Range("DI1:DI50000").Calculate
Worksheets("Control").Range("DI1:DI50000").Calculate
Worksheets("Dashboard").Range("W10:W5000").Calculate
Worksheets("Dashboard").Range("L10:L5000").Calculate
Worksheets("Dashboard").Range("Y10:Aa5000").Calculate
Worksheets("Dashboard").Range("B2:B7").Calculate
end if
强制重新计算所有相关范围。
其他方法可能不起作用,因为文件很大(~30mb)