The cell error value can be inserted into the cell, or the CVErr function can be used to test whether the cell value is an error value. The cell error value can be one of the following XlCVError constants.
constant th> | error number th> | cell error values th> tr> |
---|---|---|
xlErrDiv0 td> | 2007 td> | 0 # DIV /! |
xlErrNA | 2042 | #N/A |
xlErrName | 2029 | #NAME? |
xlErrNull | 2000 | #NULL! |
xlErrNum | 2036 | #NUM! |
xlErrRef | 2023 | #REF! |
xlErrValue | 2015 | #VALUE! |
Excel VBA tutorial: Cell error values · Examples
This example inserts seven cell error values into the A1:A7 cell area of Sheet1.
myArray = Array(xlErrDiv0, xlErrNA, xlErrName, xlErrNull, _
xlErrNum, xlErrRef, xlErrValue)
For i = 1 To 7
Worksheets("Sheet1").Cells(i, 1).Value = CVErr(myArray(i - 1))
Next i
This example checks whether the active cell in Sheet1 contains a cell error value and, if so, displays a message. This example serves as a model structure for error handlers for cell error values.
Worksheets("Sheet1").Activate
If IsError(ActiveCell.Value) Then
errval = ActiveCell.Value
Select Case errval
Case CVErr(xlErrDiv0)
MsgBox "#DIV/0! error"
Case CVErr(xlErrNA)
MsgBox "#N/A error"
Case CVErr(xlErrName)
MsgBox "#NAME?error"
Case CVErr(xlErrNull)
MsgBox "#NULL! error"
Case CVErr(xlErrNum)
MsgBox "#NUM! error"
Case CVErr(xlErrRef)
MsgBox "#REF! error"
Case CVErr(xlErrValue)
MsgBox "#VALUE! error"
Case Else
MsgBox "This should never happen!!"
End Select
End If
Read More:
- Excel VBA: cell error value
- excel VBA: Could not complete due to error 800a0011
- VBA returns “n / a” and other error information
- [Python] pandas Library pd.to_ Parameter arrangement and example of Excel operation writing into excel file
- Android:More than one file was found with OS independent path ‘res/values/values.xml
- VBA 400 error
- The built-in filter function in Excel can’t contain all the items
- Error in cov.wt(z) : ‘x’ must contain finite values only
- Remove spaces after characters in Excel cells
- Error in DESeqDataSet(se, design = design, ignoreRank) : some values in assay are negative
- Docker encountered a problem 4: yaml: Line 1: mapping values are not allowed in this context
- To solve the problem of C # calling excel interface error, prompt: the COM object of Microsoft. Office. Interop. Excel. Applicationclass is forcibly converted to the interface type “Microsoft. Offi”
- How to Disable Protected View in Microsoft Excel
- The Excel connection manager is not supported in the 64-bit version of SSIS [Switch]
- Solutions to problems in SAS 9.3 x64 importing and exporting Excel
- There was a problem sending the command to the program in Excel 2010
- Domain error in object XXX “other” domain “other” rejected values and atm913
- for k, v in k_map: ValueError: too many values to unpack (expected 2)
- Ora-00947: not enough values
- VBA “user defined type not defined” MSXML2.DOMDocument