English 中文(简体)
VBA Excel Won t Ignore“作为文本储存”
原标题:VBA Excel Won t Ignore "Number Stored as Text" Error

我认为Excel正在sen。

对我来说,我可以拿我的Excel VBA宏观软件来忽略“作为文本储存的”错误。

在称为“Main”的C71号工作单上,我有价值6135413313,Excel是警告的,是作为文本储存的。 也应该如此。 但是,在我的宏观结束时,我想消除这种无足轻重的现象。

我将我的宏观法典缩小到用于测试的光带,但三角仍然存在。 这里我说的是:

Sub test()
    Range("C71").Errors(xlEvaluateToError).Ignore = True
End Sub

如何避免这一错误? 我也尝试了<代码>Range(“Main!C71”)。 要么没有工作。

这应当是轻而易举的,但一条法典仍然行不通。 任何想法?

最佳回答

你可以尝试

Sub test()
Sheets("Main").Range("C71").Err或s(xlNumberAsText).Ign或e = True
End Sub

Sub test()
Sheets("Main").Range("C71").Value = Sheets("Main").Range("C71").Value
End Sub

The other way is you can manually disable background err或 checking.
you can find this option by clicking File - Excel Options - F或mulas and uncheck the option

it will disable err或 checking f或 all cells

background err或 checking

问题回答

Cycling through each cell in the range to test the xlNumberAsText error and set the ignore flag works (although if you have a large number of cells, this may be slow).

Sub test2()
    Call turnOffNumberAsTextError(Sheets("Main").Range("C71"))
End Sub

Sub turnOffNumberAsTextError(rge As Range)
    Dim rngCell As Range
    For Each rngCell In rge.Cells
        With rngCell
            If .Errors.Item(xlNumberAsText).Value Then
                .Errors.Item(xlNumberAsText).Ignore = True
            End If
        End With
    Next rngCell
End Sub

"Selection.Errors(xlTextDate).Ignore = True" will not work. To correct replace (xlTextDate) with one of the following values

  • (3)
  • (xlTextDate)
  • (xlNumberAsText - 1)

然而,检查贵方的Excel版本的各种价值可能有所不同。 我使用Excel 365。

Source: https://learn.microsoft.com/en-us/office/vba/api/Excel.XlErrorChecks On that page every variable list the needed value but not what Excel has assigned.

  • "Variable", "reported/needed", "Actual Excel Value"
  • xlEmptyCellReferences, 7, 8
  • xlEvaluateToError, 1, 2
  • xlInconsistentFormula, 4, 5
  • xlInconsistentListFormula, 9, 10
  • xlListDataValidation, 8, 9
  • xlNumberAsText, 3, 4
  • xlOmittedCells, 5, 6
  • xlTextDate, 2, 3
  • xlUnlockedFormulaCells, 6, 7

我没有制定规则! 当价值得到纠正时,我们的法典可能再次失败。 我会报告,但管理系统从未确定我所报告的错误。

使用文字格式的理由:储存Facebook录像 Id “4592884094151437”成为“4592884094151430”做工。





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

热门标签