2
votes

I'm trying to run a formula in excel that receives a range of cells and performs an action on them. The thing is, I would like to pass a range of cells, as well as another cell that is not in the range.

Do you know a way of doing so?

Before you suggest, I'll say that, unfortunately, the formula doesn't work like SUM, meaning, it doesn't have endless fields to enter separate values. It has one field for a range of values (to which I want to have a range and another separate cell), and after a comma, another, different, value should come (meaning, I can give it the range, comma, the other value).

Thanks guys

1
Are you writing a formula in VBA? What version of excel are you running? - Joe
please share your formula - barry houdini

1 Answers

1
votes

What you say can be achieved with VBA.

For example switch to the Visual Basic Editor (Alt+F11), create a new Module (Insert, Module), enter the following code and save.

Public Function SumPow(param1 As Range, param2 As Double) As Double
    For Each c In param1
        SumPow = SumPow + c.Value
    Next c
    SumPow = SumPow ^ param2
End Function

Now go back to your excel sheet and you can use the formula =SumPow(Range, Cell).

It will output the sum of all the values in the range raised to the power of the value in the single cell.