Solved

How to pass multiple parameters to user defined function in excel

Posted on 2009-07-15
1
234 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VS2010 Build fails to install 14 100
asp web application 3 55
ASP.NET MVC -Update model when click on <li> element 29 94
asp.net repeater server posting 5 35
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

739 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