[英]xlErrorChecks Enumeration Office 365/Excel 2016
In my current version of Excel, the enumeration of xlNumberAsText seems inconsistent with both the documentation XlErrorChecks Enumeration (Excel) and prior usage recommended on SO. 在我当前的Excel版本中,xlNumberAsText的枚举似乎与文档XlErrorChecks枚举(Excel)和SO上建议的先前用法都不一致。 It seems that particular error is Item 4; 似乎特别的错误是第4项。 whereas previous posts about clearing this error using VBA have used a constant of 3. 而以前有关使用VBA清除此错误的文章使用的常数为3。
Is this a bug in Excel 2016? 这是Excel 2016中的错误吗? Or am I doing something incorrectly. 还是我做错了什么。
Here is code demonstrating the issue. 这是演示该问题的代码。 And if you examine the worksheet after running the code, it is apparent that the error is flagged, in Excel, as NumberAsText
and not as Inconsistent Formula
. 并且,如果您在运行代码后检查工作表,很明显,在Excel中,该错误被标记为NumberAsText
而不是Inconsistent Formula
。
Option Explicit
Sub foo()
Dim I As Long
Dim B As Boolean
Dim S As String
Dim R As Range
'Save current state
B = Application.ErrorCheckingOptions.NumberAsText
'Enable
Application.ErrorCheckingOptions.NumberAsText = True
Set R = Cells(1, 1)
With R
.Clear
.NumberFormat = "@"
.Value = "1"
End With
For I = 1 To 10
S = S & vbLf & I & vbTab & R.Errors(I).Value
Next I
S = Mid(S, 2)
'Restore original state
Application.ErrorCheckingOptions.NumberAsText = B
MsgBox S
End Sub
And also, in trying to clear the error box, I must use 而且,在尝试清除错误框时,我必须使用
R.Errors(4).Ignore = True
Neither Errors(3)
, nor Errors(xlNumberAsText)
will have any affect on the error box. Errors(3)
和Errors(xlNumberAsText)
都不会对错误框产生任何影响。
I've noted other inconsistencies with the enum and the documentation: 我注意到了与枚举和文档的其他不一致之处:
Inconsistent Formula: 5
Wrong Data Type: 2
I'm not going to bother to check the rest. 我不会去检查其余的东西。 But I am going to try to report it to MS. 但我将尝试向MS报告。 Thanks to those who confirmed this problem. 感谢那些确认了这个问题的人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.