Excel range in C#

G

Guest

I am rewriting my vba routines to C# to increase speed. I have been unable to
find any help on how to pass ranges to C#.

Excel function that was called in VBA
=CalcRows(A1,A2,B1:B140,C1:C140,D1:D140)

A1 holds the type of calculation to perform
A2 holds the number of rows to calculate
B1:B140 column used in calculations (Dependent on what A1 has)
C1:C140 column used in calculations (Dependent on what A1 has)
D1:D140 columnused in calculation on B1:B140 or C1:C140
CalcRows would then return the total from the calculation.

In VBA I was able to declare a multi dimensional array as a parameter to
hold the three ranges. I have been unable to do this in C#. I reccieve a
#value error in just trying to use a multidimensional array. Ive even try to
use three spearate arrays without any luck.

How do I pass a range or ranges to C#?
 
G

Guest

I have figured out that I will need to use the Excel. Object property. THe
problem I am having now is how is the code written for something like this. I
am new to C# and have a few functions I am trying to convert. For instance
how would this be wrriten in C#

Excel cell =calctotal(5,A1:A8,B1:B8)

the five is how many rows to calculate even though more rows are sent.
I have been able to write a function to calculate when a single cell is
sent but when it comes to range I am having problems figuring this out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top