Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7032229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:54:27+00:00 2026-05-28T00:54:27+00:00

I don’t know why for some reason the Excel built-in function =SUM() can’t really

  • 0

I don’t know why for some reason the Excel built-in function =SUM() can’t really sum up the results created by the custom UDF. It appears to always end up with 0.

For example, I have got a following UDF, called myUDF, which will return the number of items.

For the cell A1:
Formula: =myUDF('ItemA') Result: 10

For the cell B1:
Formula: =myUDF('ItemB') Result: 15

So When I do =Sum(A1:B1) and put the formula in cell C1, it won’t return 25 but 0 instead.

I have tried to use some data formatting stuff (converting to numeric) but still no luck there. Has anyone here had similar issue before? Any ideas on the cause of it?

Thanks.

EDIT:
Code Sample

        public object MyUDF(string id, string pk, string param1 = "", string param2 = "", string param3 = "", string param4 = "")
        {
            object result = null;
            string strFormula;

            double n = 0;
            DateTime dt;

            try
            {
                strFormula = buildFormula(id, pk, param1, param2, param3, param4);

                result = ws.getServiceResultsDataString(id, objUser, pk, param1, param2, param3, param4);

                if (double.TryParse(result.ToString(), out n)) 
                {
                    result = n;
                }
                else if (DateTime.TryParse(result.ToString(), out dt))
                {
                    result = dt.Date;
                }
                ws.Dispose();
                objUser = null;

            }
            catch (Exception ex)
            {               
            }
            finally
            {   
            }
            return result;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:54:28+00:00Added an answer on May 28, 2026 at 12:54 am

    Is your UDF returning a number or a string that happens to contain numeric characters?

    If I go into Excel and type in ’10 (10, formatted as a string) and ’15 (15, formatted as a string), and SUM() them, I get 0.

    If I type 10 and 15 (formatted as numbers) and SUM() them, I get 25.

    Some example code that reproduces the problem would allow us to answer for sure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't really know how to formulate the title, but it should be pretty obvious
Don't know if this has been answered before. Have custom routes to users. If
Don't know why I can't reply to people on here with only a small
Don't know why but I can't find a solution to this. I have 3
Don't let below code scare you away . The question is really simple, only
Don't know how to google for such, but is there a way to query
I don't know when to add to a dataset a tableadapter or a query
For some reason, after submitting a string like this Jack’s Spindle from a text
Don't know the difference between the System.Window.Controls.TextBox and System.Windows.Forms.TextBox . Noticed that the System.Windows.Forms.TextBox
Don't know why people do not practice AJAX implementation for authentication systems. Is it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.