Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default why is this code not working?

Why am I not able to invoke this function? all I get is the same old
"#VALUE!" when I'm calling it in the excel cell as =addnumbers(10) it is
working fine and returning me a '10' onto the cell. But when I say
=addnumbers(10,20) or =addnumbers(10,20,30), it gives me a "#VALUE!"


public double AddNumbers(double Number1, [Optional] object Number2,
[Optional] object Number3)
{
double result = 0;
result += Convert.ToDouble(Number1);

if (!(Number2 is System.Reflection.Missing))
{
Excel.Range r2 = Number2 as Excel.Range;
double d2 = Convert.ToDouble(r2.Value2);
result += d2;
}

if (!(Number3 is System.Reflection.Missing))
{
Excel.Range r3 = Number3 as Excel.Range;
double d3 = Convert.ToDouble(r3.Value2);
result += d3;
}

return result;
}


What could be the problem!?
Reply
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
VBA Code Not Working tictox Excel Discussion (Misc queries) 3 October 25th 10 04:25 PM
code not working Moh Excel Programming 5 December 18th 07 08:21 AM
VB Code Is Not Working Rob Excel Discussion (Misc queries) 2 May 30th 07 05:23 PM
Code is not working....please take a look!!! tratliff[_12_] Excel Programming 5 August 24th 04 05:45 PM
For Each Code Not Working jacqui[_2_] Excel Programming 4 July 29th 03 02:44 AM


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