자료실

부자는 돈을 써서 시간을 아끼지만 가난한 사람은 시간을 써서 돈을 아낀다

vb6.0/vba

IT HUB를 찾아주셔서 감사합니다.

vb6.0/vba [vba] Cell Error Values

페이지 정보

profile_image
작성자 하나를하더라도최선을
댓글 0건 조회 6,658회 작성일 20-02-13 14:09

본문

You can insert a cell error value into a cell or test the value of a cell for an error value by using the CVErr function. The cell error values can be one of the following xlCVError constants.

ConstantError numberCell error value
xlErrDiv02007#DIV/0!
xlErrNA2042#N/A
xlErrName2029#NAME?
xlErrNull2000#NULL!
xlErrNum2036#NUM!
xlErrRef2023#REF!
xlErrValue2015#VALUE!

Example

This example inserts the seven cell error values into cells A1:A7 on Sheet1.

VBCopy
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 displays a message if the active cell on Sheet1 contains a cell error value. You can use this example as a framework for a cell-error-value error handler.

VBCopy
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


Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.

댓글목록

등록된 댓글이 없습니다.