Excel Custom Function

Copper Contributor

I am trying to write a custom function for rounding a set of data. So that I can reuse it for each form I create and not have to rewrite the whole function.

I have tried to use Macros and VBA but frankly I have no idea what to write in them, I tried an assortment of things but none worked.

The code i wish to simplify into its own function:


so for example F3 contains the value of 31.2



= 32


Can I make this it’s own function?

4 Replies
not have to rewrite the whole function.

just short length of function?
how about name the formula as f?

then =f(...)


To name an Excel formula, you can follow these steps:

Select the formula cell, for example, A1.

In the formula bar, enter the desired name, for example, "my_formula", and press Enter. The formula in cell A1 will still exist.

Select cell A1 and click the "Name Manager" button (under the "Formulas" tab).

In the "Name Manager" dialog box, click the "New" button.

In the "New Name" dialog box, enter the name "my_formula" (or any other name you want) and in the "Refers to" field, enter the formula "=let(x,1,3+x)" (or any other formula you want).

Click the "OK" button and then close the "Name Manager" dialog box.

Now, you can type "my_formula" in any cell, and Excel will automatically replace it with the formula "let(x,1,3+x)".
You can also name formulas with parameters by following similar steps. Here is a link to Microsoft's documentation on using names in formulas: https://support.microsoft.com/en-us/office/define-and-use-names-in-formulas-4d0f13ac-53b7-422e-afd2-....


thank you for your help, I am still confused on forming the whole thing.

What can I use in the formula to set reference to the cell selected by the user.

for example, if I want to do simple addition:


F3 and F4 were each clicked on the user after starting the formula.

or in your example “x”

For my formula,

I want the user to insert the formula name and select the desired cell they wish to use. What do I write to reference to the current selected cell by the user in:


name as =sum(x+y)
then =my_formula(x,y)

as to

I am not familiar with formlas,so I do not know what is the exact mean about your function.

Hope other experts come with other suggestions.