English 中文(简体)
如何确定与Excel VBA合著的整个工作手册中是否有一处错误
原标题:How do i determine if an error is in any cell in the entire workbook with Excel VBA
  • 时间:2011-11-22 17:00:06
  •  标签:
  • excel
  • vba

Q: 如何确定与Excel VBA合著的整个工作手册中是否有一处错误?

通常的错误将分为0或0数值错误,但这一清单并非详尽无遗(或是不是)。 - 不知道是否存在更多情况

是否有办法确定一个囚室是否含有错误,然后在我手稿中绕过进一步处理,而不必出示假装/警告/警报/器具。

......

          if value in current.Workbook.cell is error then go to <jump>
           OR
          if value in old.Workbook.cell is error then go to <jump>

<代码>jump 是报表结尾处的标识,但载于正文内。

该书将两本工作书的数值进行比较,并用颜色更新现行工作手册,以显示差异。

我完全没有艾滋病协会的经验。 但是,这只字面被打上。

感谢您。

最佳回答

您可使用功能,对有错误的电池进行过滤。 例如:

If VarType(ActiveCell.Value) <> vbError Then
      do something
End If

<代码>VarType功能对于验证数据类型也非常有用。 例如,如果你的法典期望有日期价值,但有时会遇到案文,那么你就可以利用这一职能来审查数据,并妥善处理例外情况。

问题回答

这里有一套在“直接窗口”、“工作单”名称、手机地址和公式中记录下来的密码,如果存在“电子表格”公式错误。

Dim ws As Worksheet, r As Range

For Each ws In Worksheets
    For Each r In ws.UsedRange
        If IsError(r.Value) Then
            Debug.Print r.Parent.Name, r.Address, r.Formula
        End If
    Next
Next

鉴于你最初的问题是,你如何发现与传统助产士合作手册的任何单元中的错误,你应当寻找一种非常有效的方法——检查每个单元都非常昂贵的时间!

这方面有两个选择:

  1. Use Excel s SpecialCells to shortcut the process
  2. use my Mappit! addin which is configured to report on spreadsheet errors

For SpecialCells please see the code below. This takes advantage of the ready-made collection of errors that exist as formulas

请将此constants也收集错误,这样,如果你在公式错误上复制了特别的过去,那么你需要使用。 Set rng1 = ws.Cells.SpecialCells (xlConstants, xlErrors),用于检测这些气体。

You can use also detect SpecialCells manually by

  • Select all cells in the area of interest
  • Press F5
  • Click Special
  • select Errors under Formulas (or Constants )

enter image description here

请注意,在xl2010年之前,有以下限制:8192地区,由特委会处理

Sub ErrorList()
    Dim ws As Worksheet
    Dim rng1 As Range
    Dim strOut As String
    For Each ws In ActiveWorkbook.Sheets
        Set rng1 = Nothing
        On Error Resume Next
        Set rng1 = ws.Cells.SpecialCells(xlFormulas, xlErrors)
        On Error GoTo 0
        If Not rng1 Is Nothing Then strOut = strOut & (ws.Name & " has " & rng1.Cells.Count & " errors" & vbNewLine)
    Next ws
    If Len(strOut) > 0 Then
        MsgBox "Error List:" & vbNewLine & strOut
    Else
        MsgBox "No Errors", vbInformation
    End If
End Sub

处理该问题还有另一种方式:在您的法典中添加<>关于后继<>代码>(通常只是放在左边)。

如果囚室有错误,它就只能跳出它,然后移到 lo的下一个部分:





相关问题
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 ...

热门标签