Function as cell reference?

fhobbs

New Member
Joined
May 12, 2016
Messages
6
Can you write a formula where the function you want to use is a variable (cell ref)?
I’d like to be able to change the function in a formula from a cell reference. Ex.
=max (A2:A3), where the function “max” is defined from a cell reference in cell A1, so I can change the function to min, sum, etc by changing cell A1.
 
The VBA codes work fine. Thank. But in the formula =EVAL(D1 & "(A1:B1)") the "(A1:B1)" is not seen as a cell ref so it does not increment when copied down so it only works for the first of many row. I tried =EVAL($D$1&"("&A1:B1&")") which makes A1:B1 a cell ref but not a good equation. Ideas?
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
That is because it is a string in our formula (we are using string to build the formula, and then use EVAL to evaluate it).
We can use the ROW() function which dynamically returns the row number of the cell that it currently resides in, i.e.
Code:
=EVAL($D$1 & "(A" & ROW() & ":B" & ROW() & ")")
and then that will return the desired result when you copy it down the row.
 
Upvote 0
Excuse me if I am missing something, but it looks like what you where wanting was this formula;

=CHOOSE(IF($D$1="MIN",1,IF($D$1="MAX",2,IF($D$1="SUM",3))),MIN($A$2:$A$3),MAX($A$2:$A$3),SUM($A$2:$A$3))

Of course setup D1 with a drop down menu of a list of the three functions you mentioned.

If I missed something, please forgive my interruption...
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,659
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top