Forum Discussion

Werner_Geiger's avatar
Werner_Geiger
Brass Contributor
Feb 11, 2022
Solved

How to return #Value! or #Name? from VBA?

How can I return the standard spreadsheet errors #Value! or #Name? from a VBA-function to the calling Cell?   With the following little function doSomething one can write the formula    =doSomet...
  • Werner_Geiger's avatar
    Feb 12, 2022

    Werner_Geiger 

    Now I found it: You have to use

    ' use nbr = xlErrDiv0, xlErrNA, xlErrName, xlErrNull, xlErrNum , xlErrRef, xlErrValue
    doSomething = CVErr(nbr)

    If called from a spreadsheet this produces:

    #DIV/0!, #NA, #Name!, etc.

Resources