Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to Return #N/A from a formula


Hi,

i have some VBA code in the custom-made formula
Getprice(Date;ProductCode) that fetch data from a db and return either
a number or an error (by means of a text explanation) I would like to
return #N/A when there is an error and the value otherwise. The problem
is that if i write:

Getprice = "#N/A"

excel puts in the calling cell mere text and in the sheet #N/A isn't
considered as a real NOT AVAILABLE ... Therefore if I sum that cell
with another containing a number it doesn't show #N/A but simply avoid
considering the cell containing #N/A in the calculation of the sum ...

Thanks in advance for your help

Sorry for my bad english

Paolo

Italy


--
kayard
------------------------------------------------------------------------
kayard's Profile: http://www.excelforum.com/member.php...o&userid=24716
View this thread: http://www.excelforum.com/showthread...hreadid=569327

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default How to Return #N/A from a formula

Ho Paolo,

CVErr(xlErrNA)

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"kayard" wrote in message
...
|
| Hi,
|
| i have some VBA code in the custom-made formula
| Getprice(Date;ProductCode) that fetch data from a db and return either
| a number or an error (by means of a text explanation) I would like to
| return #N/A when there is an error and the value otherwise. The problem
| is that if i write:
|
| Getprice = "#N/A"
|
| excel puts in the calling cell mere text and in the sheet #N/A isn't
| considered as a real NOT AVAILABLE ... Therefore if I sum that cell
| with another containing a number it doesn't show #N/A but simply avoid
| considering the cell containing #N/A in the calculation of the sum ...
|
| Thanks in advance for your help
|
| Sorry for my bad english
|
| Paolo
|
| Italy
|
|
| --
| kayard
| ------------------------------------------------------------------------
| kayard's Profile: http://www.excelforum.com/member.php...o&userid=24716
| View this thread: http://www.excelforum.com/showthread...hreadid=569327
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default How to Return #N/A from a formula

Check out CVErr function in the help and various built-in xlErr Enum values:
e.g.

Public Function GetPrice() As Variant
GetPrice = CVErr(xlErrNA)
End Function

NickHK

"kayard" wrote in
message ...

Hi,

i have some VBA code in the custom-made formula
Getprice(Date;ProductCode) that fetch data from a db and return either
a number or an error (by means of a text explanation) I would like to
return #N/A when there is an error and the value otherwise. The problem
is that if i write:

Getprice = "#N/A"

excel puts in the calling cell mere text and in the sheet #N/A isn't
considered as a real NOT AVAILABLE ... Therefore if I sum that cell
with another containing a number it doesn't show #N/A but simply avoid
considering the cell containing #N/A in the calculation of the sum ...

Thanks in advance for your help

Sorry for my bad english

Paolo

Italy


--
kayard
------------------------------------------------------------------------
kayard's Profile:

http://www.excelforum.com/member.php...o&userid=24716
View this thread: http://www.excelforum.com/showthread...hreadid=569327



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
if formula return Theresa Excel Discussion (Misc queries) 4 September 16th 08 03:53 PM
No return for formula MPAVLAS Excel Worksheet Functions 2 October 5th 07 05:45 PM
Formula to Return Last Non-Zero Value in Row Ken Hudson Excel Worksheet Functions 4 November 15th 06 05:31 AM
Why does my formula return zero? was Excel Discussion (Misc queries) 11 May 26th 05 09:49 PM
Date formula...help with return on formula Juco Excel Worksheet Functions 2 January 28th 05 09:28 PM


All times are GMT +1. The time now is 02:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"