Declaring variables in Excel Cells

ExcelExcel Formula

Excel Problem Overview


Is it possible to declare variables in Excel cells and use them as parameters for formulas in other cells?

For example I would declare var1=10 in one of the cells. In another cell I would use var1 for calculation like: =var1*20.

Excel Solutions


Solution 1 - Excel

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

Solution 2 - Excel

I also just found out how to do this with the Excel Name Manager (Formulas > Defined Names Section > Name Manager).

You can define a variable that doesn't have to "live" within a cell and then you can use it in formulas.

Excel Name Manager

Solution 3 - Excel

The lingo in excel is different, you don't "declare variables", you "name" cells or arrays.

A good overview of how you do that is below: http://office.microsoft.com/en-001/excel-help/define-and-use-names-in-formulas-HA010342417.aspx

Solution 4 - Excel

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionManojView Question on Stackoverflow
Solution 1 - ExcelAKXView Answer on Stackoverflow
Solution 2 - ExcelColorado TechieView Answer on Stackoverflow
Solution 3 - Exceluser3825260View Answer on Stackoverflow
Solution 4 - ExcelymihereView Answer on Stackoverflow