Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I do this 'cuz I don't to have to remember -4123 versus -4163 or whatever,
if bFormulas then LookIn = xlFormulas else LookIn = xlValues Don't declare the bFormulas parameter to your function as a Boolean. Declare the variable as the enum type that contains xlFormulas and xlValues. Doing so will give you Intellisense support when writing the call to the function. E.g, Function Whatever(blah, blah, blah, LookIn As XlFindLookIn) When you are typing in the call to Whatever and you get to the LookIn parameter, you'll get a drop down list of the valid values for that parameter. No need to memorize any numbers -- just pick from the list. Note that it is perfectly legal to assign any numeric value to an enum type, even if that enum type doesn't define that value. For example, it is perfectly legal to use Whatever(LookIn:=1234) even though 1234 is not an enumerated value of XlFindLookIn. You won't get a compiler error and you won't get a run time error. What the code does with an invalid value is anyone's guess, but it will run in one fashion or another. (In VBNET, you get an IsDefined method to test whether a value is valid for a specific enum, but sadly you don't get that in VBA.) In addition to using the built in enum data types, you can create your own and get intellisense support for working with them. See http://www.cpearson.com/Excel/Enums.aspx for more detail. Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Fri, 28 Aug 2009 17:06:02 -0700, Neal Zimm wrote: Matthew - Thanks. We agree. I use much the same optional variables as you in the sub statement with this exception, and I did read that your look at the code was brief. I use boolean variables where there are two choices e.g. optional bFormulas as boolean = true in the code: if bFormulas then LookIn = xlFormulas else LookIn = xlValues I do this 'cuz I don't to have to remember -4123 versus -4163 or whatever, when I type the call Macro(xxxx xxxx xxxx statement and the optional stuff appears. i can remember bFormulas; true or false better Thanks again. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
.Find method with numeric and date values, Aug2009 | Excel Programming | |||
Set Find to look in Values instead of Formulas by default? | Excel Programming | |||
Adjusting rows versus columns for formulas | Excel Programming | |||
how to find if an excel sheet has any hidden values in a cell in VB.NET | Excel Programming | |||
How do I avoid referencing hidden values in formulas like OFFSET? | Excel Worksheet Functions |