# How to assign a value to a name in a spreadsheet (Google Sheets)

I would like to be able to give a particular name, such as Math_class1, a corresponding value such that when I list various of them in a column that I see their correct names and at the bottom the sum of their values and be able to easily move names around and have the sums quickly change.

This is how I want it to look.

• I am not sure I understand what you want. Where is `Math_class1` in that screenshot supposed to be? By a "corresponding value" you mean a numerical one? Commented Mar 23, 2021 at 19:09
• Math_class1 was an example. And yes I mean to give each name a numeric value. Commented Mar 23, 2021 at 19:10
• Oh, ok. So you mean that each value shown in column `B` in that screenshot has a numerical value assigned to it? E.g. `CSP = 5`, `EECS = 7` and so on? Commented Mar 23, 2021 at 19:11
• That's what I want yes. And so that if I change the name it automatically sums up the newly placed classes. Commented Mar 23, 2021 at 19:15

I would do this with two sheets.

# Sheet 2

Create a second sheet (`Sheet2`) where numerical values are assigned to each string (subject?), as in:

Subject (Column A) Credits (Column B)
CSP 5
BOOKS 7
EECS 3
Math_class1 5
Physics 4
UC 3

# Sheet 1

Then, back to `Sheet1` (the main sheet).

I use the same structure as in your screenshot, meaning that all relevant subjects are in column `B`.

Add the following to column `C2` and hide it with white color:

``````=IFERROR(LOOKUP(B2, Sheet2!\$A:\$A, Sheet2!\$B:\$B), 0)
``````

(and analogously for `C3`, `C4` etc.)

You will then get the total results with:

`=SUM(C:C)`.