0

it is possible to declare a variable in excel lets say N=10, then if i type letter N in a cell and that cell makes part of a sum, that cell will be counted as 10?

2 Answers 2

1

Go to Formulas > Define Name there define your variable.

Then open VBA with Alt + F11 Insert a module and there use this function:

Function EVAL(rng As Range) As Variant EVAL = Evaluate(rng.Value) End Function 

You can use the function in a formula: =EVAL(Cell where is your var N)

Sign up to request clarification or add additional context in comments.

Comments

0

You can name a cell by selecting it, clicking the field with its address (in upper-left corner) and entering name (in your example "N"). Value in this cell is value on your variable. Good idea is to make separate sheet that will contain variables (you'll avoid mess), but it's not necessary.

And then you can use it in formulas, f.e.: =A1*N. But remember, if you want just fill cell with its value, use =N instead of N.

3 Comments

More info on Microsoft site: support.office.com/en-us/article/…
If i do that the value 10 will be displayed in that cell where i put =N, i need that N will be displayed in the cell not its own value and only in the sum N to be replaced with 10
So I don't think you will be able to do that, as Excel has to distinguish letter N and variable N.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.