LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Tricky one ( variant type text to be unaffected by a minus)

I have written a function


findNewNominal(NomCode as Integer) as Variant

if x exists in a certain range
findNewNominal = an integer corresponding to nomCode

else
findNewNominal = "Nominal Code does not exist"


So in conclusion my variant is either an integer or text



Now when calling this function (i never know in advance whether text or an
int will be returned)
I sometimes want the negative result of the integer returned.


So in some cells i say = - findNewNominal(a number)

This fine provided an integer is returned.
However I want it obvious when the function reports a nominal code could not
be found. The
problem is the '-' turns the text (Nominal Code Not Found) to a 0 (so it
looks like the integer zero has been returned when in fact the nominal
code couldnt be found.

Is there anyway of returning a variant type in my function when if it text,
it is still displayed as such and not
effected by the preceding minus to the function call.

(i cannot really remove the minus, as if an int is to be returned i need on
certain occassions the reverse sign of this)

Many thanks
James


 
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
Excel rounding bug for input to Variant data type Greg[_24_] Excel Programming 0 January 18th 06 08:36 PM
how to redim the type of variant element lvcha.gouqizi Excel Programming 5 October 25th 05 07:05 PM
Type mismatch accessing variant array too many times peter Excel Programming 6 February 12th 05 10:07 PM
Variant Array with String Values - Type Mismatch jamiee Excel Programming 2 March 7th 04 03:39 AM
How to check a Variant for its data type TBA[_2_] Excel Programming 5 January 9th 04 11:04 PM


All times are GMT +1. The time now is 11:12 PM.

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"