![]() |
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!? |
All times are GMT +1. The time now is 12:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com