tags:

views:

4137

answers:

2

Is it possible to declare variables in Excel cells and use it as parameter for formula in other cells? For example I would declare var1=20 in one of the cells. In other cells I would use var1 for calculation like : =var1*20.

Thanks...

A: 

You can't declare a variable in a cell, but you can use (hidden) cells as variables. E.g., you could hide Column C, set C1 to

=20

and use it as

=c1*20

Alternatively you can write VBA Macros which set and read a global variable.

Edit: AKX renders my Answer partially incorrect. I had no Idea you could name cells in Excel.

ymihere
+7  A: 

You can name cells. This is done by clicking the Name Box (that thing next to the formula bar which says "A1" for example) and typing a name, such as, "myvar". Now you can use that name instead of the cell reference:

= myvar*25
AKX
For reference, you can also name groups of cells. Using their values is a bit trickier, but it can be done :)
Damovisa
@AKX: That was a nice trick! Thanks... @Damovisa: Thanks for the additional tip!Also is there a way of displaying the Cell name we assign in another cell. I would like to display the cell name in the adjacent cell so that the user is able to identify the cell name without clicking it.
Manoj
Note:- This is particulary useful when copying formulas. Excel is very "helpful" and adjusts any cell references in the formula. Quite often you want the references to reamin fixed - refering to a nemed cell does the trick.
James Anderson