?
Solved

How to pass multiple parameters to user defined function in excel

Posted on 2009-07-15
1
Medium Priority
?
239 Views
Last Modified: 2012-05-07
Hi Experts,

I am working on an Excel add-in and want to pass multiple parameter to a function which i defined.

for example if i send the parameters as follows it doesn't work.

  public int AddNumbers(params int[] Numbers)
        {
            int Result = 0;
            for (int i = 0; i < Numbers.Length; i++)
            {
                if (i==0)
                {
                    Result = Numbers[i];
                }
                else
                {
                   Result = Numbers[i - 1] + Numbers[i];
                }
               
            }
            return Result;
        }

but if i use the function as follows it works,

        public int Addtest(int a, int b){

            int test = 0;
            try
            {
                test = AddNumbers(new int[] {a,b });
            }
            catch (Exception)
            {
               
                throw;
            }
            return test;
        }

My question is, I have a user defined function in my excel add-in project  and want to pass last parameters as a parameter array not as an optional range.

public object DummyFunction(string strDummy1, string strDummy2, object objDummy, params string[] strInputs)

0
Comment
Question by:Kadakal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
chriswilsonuk earned 1000 total points
ID: 24884130
I don't think it's possible to pass arrays into Excel functions.

You will need to make this a Range, which is effectively the same thing except it has the potential to have incorrect data types - so you'll need to filter those.
0

Featured Post

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question