naming a function same way naming a range

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I have nested if() i.e. =if(cond1, "a", if(cond2,"b",if(cond3,"c",f)))
I want to know if I can name that function to for example XYZ and use that name to pass it to another function instead of passing the whole function. Similar idea of naming a range A1:A20 as ABC and then use it as =sum(ABC). Thank you.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
You can name the cell that formula is in, and then refer to that name in another formula. You can't name the actual formula and then use it like "=MyFormula(A1) ", no...is that what you're asking?
 
Last edited:
Upvote 0
Yes, you can do that. In the 'Refers to' box, just type in the formula as you would type it into a cell. However, as I tested it, the formula got messed up after first entry, so I had to go back into the Name Manager and fix the ranges.

By doing this, the name then references the result of the formula you put in.

Here's what I did:

I made an entry in the Name Manager for this formula and named it "Fives" and typed that formula into the "Refers To" box:

=IF(B1="x",B2,IF(C1="x",C2,D2))

The SUM formula then returned the sum of E2 and whatever the result of my formula was, 5, 10, 55, etc.

And after further testing, you don't even need to put the named formula on the sheet anywhere.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD]E
[/TD]
[TD]F
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]named formula here
[/TD]
[TD]x
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD][/TD]
[TD]5
[/TD]
[TD]10
[/TD]
[TD]55
[/TD]
[TD]100
[/TD]
[TD]=SUM(Fives,E2)
[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

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