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: 62
Default A tricky one: anything like an array of functions?

Hello

I am trying to do something specific but not sure of the right syntax
to use in VBA. Basically I have the option to do several kind of
calculations, on some given variables like

Option 1: do the sum
Option 2: take the max
Option 3: do the product

Now in my code I have a parameter that will say whether I should do
the calculation of the option 1, 2 or 3.

The easy way to formulate it is simply by doing a select/case, or by
running a loop going through every option and comparing if this is the
option I want to use.

Now if the number of different options is significant, and this is
looped many times, it can be quite time consuming and unnecessary.
What I would like to do is having an integer "N" that would say which
calculation to do. N would be worth 1, 2 or 3 and I would go directly
to the right option, but I am stuck there. How would you select a
specific calculation based on N?

Ideally I would like to have a sort of array of functions
"TheArrayOfSubs" (for instance subs) such that I can do

call TheArrayOfSubs(2)

and it would directly run the sub corresponding to option 2.

Or something like that.

Would any one have an idea of how to code that?

thanks
Charles

 
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
Tricky array problem…. MarkCCB Excel Discussion (Misc queries) 3 August 6th 06 11:04 AM
Tricky Tricky episode 2!!! mhax[_13_] Excel Programming 5 July 21st 06 03:15 PM
efficiency: database functions vs. math functions vs. array formula nickname Excel Discussion (Misc queries) 2 July 14th 06 04:26 AM
Need help with a tricky problem of placing a number within an array... [email protected] Excel Worksheet Functions 2 January 23rd 06 09:36 PM
Tricky array formula issue - Using array formula on one cell, then autofilling down a range aspenbordr Excel Programming 0 July 27th 05 03:59 PM


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