Solved

How to pass multiple parameters to user defined function in excel

Posted on 2009-07-15
1
233 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
1 Comment
 
LVL 1

Accepted Solution

by:
chriswilsonuk earned 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
RegEx with optional part 4 52
Why use this lambda? 12 60
ASP.NET - Why is accordion not working? 3 45
C# DataTable (in memory) vs SQL Lookups 4 31
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

713 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