[英]xlErrorChecks Enumeration Office 365/Excel 2016
在我當前的Excel版本中,xlNumberAsText的枚舉似乎與文檔XlErrorChecks枚舉(Excel)和SO上建議的先前用法都不一致。 似乎特別的錯誤是第4項。 而以前有關使用VBA清除此錯誤的文章使用的常數為3。
這是Excel 2016中的錯誤嗎? 還是我做錯了什么。
這是演示該問題的代碼。 並且,如果您在運行代碼后檢查工作表,很明顯,在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
而且,在嘗試清除錯誤框時,我必須使用
R.Errors(4).Ignore = True
Errors(3)
和Errors(xlNumberAsText)
都不會對錯誤框產生任何影響。
我注意到了與枚舉和文檔的其他不一致之處:
Inconsistent Formula: 5
Wrong Data Type: 2
我不會去檢查其余的東西。 但我將嘗試向MS報告。 感謝那些確認了這個問題的人。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.