English 中文(简体)
我如何确定是否完成了计算,或发现中断计算?
原标题:How do I determine whether calculation was completed, or detect interrupted calculation?
  • 时间:2012-01-12 23:14:22
  •  标签:
  • excel
  • vba

I have a rather large workbook that takes a really long time to calculate. It used to be quite a challenge to get it to calculate all the way, since Excel is so eager to silently abort calculation if you so much as look at it.

为了帮助缓解这一问题,我制定了一些《传统做法法》,以表格形式启动计算,其结果是,中断计算过程并不容易,但还是有可能。 (我可以很容易地这样做,点击表上的X,但我想还有其他办法)

我不想采取更多步骤来尝试和更难打断计算,而是希望守则能够发现计算是否完整,从而可以通知用户,而不是盲目地将我守则中的其他步骤输入。 迄今为止,我找不到这样做的任何办法。

我看到了申请的提法。 计算国,但数值在我打断计算之后为xlDone,即使我在几秒后中断计算(通常需要一小时左右)。

I can t think of a way to do this by checking the value of cells, since I don t know which one is calculated last. I see that there is a way to mark cells as "dirty" but I haven t been able to find a way to check the dirtiness of a cell. And I don t know if that s even the right path to take, since I d likely have to check every cell in every sheet.

中断计算的行为不会产生错误,因此,我的欧洲复兴开发银行没有启动。

Is there anything I m missing? Any ideas?

任何想法?

问题回答

我认为,你需要执行(如果你在2007年或之后重新提出申请)的trick,就是在申请中处理。 计算活动在计算完成后提出,和<>em>后,没有未决问题。

如果您以前从未参与过在荷兰律师协会的活动,则从.cpearson.com得到很好的概述。

关于地位条码,右侧是<条码>。 计算(N processors) 页: 1 在重新计算时,X% 是完成多少。 如果你看不到案文,则不重新计算。

使用2010年办公室,但应该有所有版本。 这只是轻而易举的,因此很容易被误导。

上文Charles Williams(MSDN)的解决办法对我来说是可行的,当时我有1,000名VLOOKUP的 s子,由于该法典正在改变研究价值,因此不得不重新计算。 计算结果没有达到100%。

在我的从属地一开始,该法典就执行。

Application.Calculation = xlManual

This eliminated unnecessary calculations by Excel until I was ready.

如今,该法的关键执行点是:

Application.Calculation = xlAutomatic
ThisWorkbook.ForceFullCalculation = True
Application.Calculate

在强迫Excel进行充分计算之后,该法典可以节省结果,并移至下一个版本......但在这样做之前。

ThisWorkbook.ForceFullCalculation = False
Application.Calculation = xlManual

最终成员

Application.Calculation = xlAutomatic  

I ve never actually used it but I think this might work to prevent calculation from being interrupted.

<编码>应用。 Key = xlNoKey

I think I m hearing that you need a way to monitor whether each step within the calculations being performed was executed.

假设你不再有兴趣重新设计工作手册,以使用比电子表格计算更容易跟踪的方法(如在VBA或Pivot表内进行挥发性计算),这或许有助于你:

在VB中,你可以使用、可计算,计算,将整个工作表格定为“Dirty”(计算方法),然后重新计算。 这一进程与你当前进程的主要区别是,我们将以人工方式开展这些行动one worksheet。 通过在万国邮局内部的某个时间启动计算单,您将能够采取额外的中间行动,以跟踪你在计算过程中的距离。

Please note that this approach assumes a fairly linear workbook structure such that your workbook will produce the correct results if we first recalculate Sheet1, then Sheet2, Sheet3, and so on, in whatever order you wish. If your formula dependencies are more "spaghetti" than linear, this probably won t work for you. It also assumes you are working in Excel 2000 or later.

For example, you could write a VBA routine that accomplishes the following steps. You will need to know your dependencies in order to know which calculations must come before others, and start with the worksheet in a "clean" state where no calculations are currently pending.

<>Step 1 在需要重新计算的第一个工作表格中确定积极表格

<>Step 2 2. 确定人工计算方式如下:

    Application.Calculation = xlCalculationManual

<>Step 3:“Dirty” 整个活页如下:

    With ActiveSheet

    .EnableCalculation = False

    .EnableCalculation = True

Step 4: Initiate a recalculation for this worksheet only (not the entire workbook) using:

    .Calculate

    End With

请注意,如果计算方式自动确定,第3步将在整个工作手册中重新计算。 通过使用手法和手法,我们正在把这一计算限制在目前的表格中。

现在,你们已经推迟并重新安排了第一张纸张(hur!)。 现在,通过将上面第3和第4步骤纳入“For/Each或For/Next loop”,你可以在工作手册中重复每个工作单的程序。 同样,确保你知道需要计算你的工作表格的顺序(如果需要订单)。

现在,通过在你行程中形成一个反变量,你可以跟踪你在计算时的距离,每当你完成一次工作单计算时,更新你的反变值。 例如,在你重新计算工作单之后,你可以将反面价值确定为现值+1,并将结果储存在全球变量中(因此,即使在您的传统目的之后,结果仍将存在),也可以储存在你的工作桌上。 这样,你就可以在计算完成或中断之前检查这一价值,看看有多少工作表格得到更新。

如果你在工作手册中的工作表格相对较少,那么在时间上而不是在表格上可以采用同样的方法。

I won t go into detail about how to construct a "counter", loops, or global variables here, but if needed, this information can be easily found using your favorite search engine. I would also highly recommend re-enabling automatic calculations once you are done as it is easy to forget that it s been set to manual mode.

I hope this works for you - for more information on calculation modes and recalculation, this is a helpful link: http://msdn.microsoft.com/en-us/library/bb687891.aspx

也许以下工作是可行的:

Do Until Application.CalculationState = xlDone
    DoEvents
Loop

我要说的是,我对它进行了测试,我也不知道申请的功能如何有力。 计算 事实上,国家要确定是否发生了完全的计算,而不是打断了计算过程和标明计算国的情况。

Private sub SomeCodeThatGeneratesFormulas
    Application.Calculation = xlCalculation.xlCalculationManual
     ...Some formulas are copied here 
    Application.OnTime DateTime.DateAdd ("s",.01,DateTime.Now), "Module1.CalculateFullRebuildAndSubsequentSteps"  By using Application.OnTime, this method will be called in a way that locks the end-user out of providing inputs into Excel until the calculation itself is complete.
end sub

public sub CalculateFullRebuildAndSubsequentSteps
    Application.CalculateFullRebuild
     ...Do next steps, i.e. paste as values 
end sub

Excel的管线可以是平线。 也就是说,为了完成某些任务,人们避免使用中间栏/行,储存(临时)数据,因此,各阵列必须从每开始时就重新计算工作人员,从而真正缓慢。 我的建议是:

  1. fix arrays to avoid multiple searches. Use hidden cells or even hidden sheets
  2. Avoid using A:A and rather use A1:A1000 specially in excel 2007 or later
  3. use formulas to equal zero or error (ex: NA()) while previous items aren t calculated, so you can clearly see if an operation is done at all.
  4. some VBA could be used to inject formulas in place one step at a time, perform calculations, then proceed to next step, but this could mean lots of work...




相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...