segregating passed range by rows and columns

M

Michael Malinsky

I have the following:

Function MySum(ParamArray argumentArray() As Variant) As Double
Dim argumentCount As Integer
Dim cell As Range
Dim i As Integer
Dim sum As Double

sum = 0

argumentCount = UBound(argumentArray)

For i = 0 To argumentCount
For Each cell In argumentArray(i).cells
sum = sum + cell.Value
Next
Next i

cfoot = sum

End Function

This works fine for summing a non-continuous range of cells. However, what
I'd like to do is segregate the cells by row and column so if I used the
following formula:

=mysum(C3,C7,A9,B9)

The function would segregate the numbers in column C from those in row 9. I
basically want to limit the user to selecting info from one row and one
column then sum the values from the cells in the row and comparing to the
sum of the values in the column. For those of you familiar with the
terminology, I want to create a function that will crossfoot a column and a
row to verify that the sums match, except I want to do this for
noncontinuous cells in the row and/or column.

TIA.
--
Michael J. Malinsky
Pittsburgh, PA

"I am a bear of very little brain, and long
words bother me." -- AA Milne, Winnie the Pooh
 
T

Tom Ogilvy

What are your constraints. Will it always be columns first, then rows
second. Will there always be an even number and half would be columns, half
would be rows. Or do you want the code to assess the commonality and if
so, what can be assumed.
 

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