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: 100
Default Here's how to require user to pass a particular param type to a cellfunction (intercepting #VALUE).

I want to share something that took me some hrs. to learn, to possibly
spare others my pain.

I wrote a function the user can use in a cell, e.g.:

public function Plural(ByVal S as <immaterial here) as string
Plural = S & "s"
end function

But I can only handle an address or range name, not a literal string,
i.e.:

=Plural($A$1) not =Plural("apple")

I think I've found the solution by making the param a Variant and
using TypeName:

public function Plural(ByVal S as Variant) as string
if TypeName(S) = "Range" then
Plural = W & "s"
else
Plural = "Paisan, you sick in da head? Use a range, not a literal
string."
endif
end function

***

Pa(ren)thetically, what the hell is with VarType?

When TypeName is "Range", it's 8. But when it's "String", it's ... 8.

I mean, Douglas Adams's 42 would be more informative.

***
 
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 < equal to named list require user to fill out desired columns? Matt Pierringer Excel Programming 2 March 7th 07 10:04 PM
Type Mismatch: array or user defined type expected ExcelMonkey Excel Programming 4 July 6th 06 03:40 PM
How do i require a user to enter a data in a field in Excel Fred Excel Programming 1 January 25th 06 06:26 PM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
How to Pass Control from VBA to user and return needyourhelp Excel Programming 3 June 7th 05 12:53 PM


All times are GMT +1. The time now is 12:14 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"