Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A "constant" in google spreadsheet?

Say I have 2 columns: (this is extremely simplified)

  • Data = a number
  • Result = Data * 1.2

I can put B2 = A2*1.2, then drag and drop B2 down...
enter image description here
and it fills all the other cells, which is perfect.
enter image description here

But can I put this multiplier (1.2) somewhere as a "constant"? (for clarity and being easily editable)

Say I put it in E1, and set B2 = A2*E1.
Now I can't drag and drop anymore (because E1 becomes E2 E3 and so on)
enter image description here
In this example, is there a way to make E1 stay as you drag it down?

like image 987
Aximili Avatar asked Apr 04 '16 06:04

Aximili


People also ask

How do you make a Google sheet constant?

If you copy the formula down Column C, both cell references will change (A2 to A3 and B2 to B3, etc.). Say you want to keep cell A2 constant. To do that, click on the cell reference in the formula bar (A2), and enter $ before column and row ($A$2). You can also press F4 on the keyboard to make variable cell constant.

How do I keep a value constant in Google Sheets?

You can use an absolute reference to keep a row and/or column constant in the formula. An absolute reference is designated in the formula by the addition of a dollar sign ($). It can precede the column reference, the row reference, or both.

How do you add a constant to a column in sheets?

To add a value to a range of cells, click on the cell where you want to display the result, and enter = (equal) and the cell reference of the first number then + (plus) and the number you want to add.


3 Answers

Short answer

Use an absolute cell reference or a named range

Explanation

Instead of E1, which is a relative cell reference, use $E$1 which is an absolute cell reference.

An alternative is to to assign a name to the cell E1, let say, "constant"

In the first case the formula will be

=A2*$E$1 

In the second case

=A2*constant  

References

  • Spreadsheet - Wikipedia
  • Name a range of cells - Google Docs Editors Help
like image 135
Rubén Avatar answered Oct 07 '22 14:10

Rubén


Can you try this in your formula?

Cell B2 type

 =A2*$E$1

Then there is no need to drag it down on column E, it will all follow E1. I believe this solves the problem.

If you really want to drag it down, then why not just put Cell E2

=E1

So that even when you drag, the value will remain 1.2

like image 24
Kelvin Chong Avatar answered Oct 07 '22 14:10

Kelvin Chong


I understand that you are asking for "A “constant” in Google spreadsheet?" and later on a "drag down" solution.

You can use the accepted answer, OR ...
Instead of having to drag down (increasing the number of formulas)

Use a single formula in B2

=ArrayFormula(A2:A6*E1)  

enter image description here

You can even use it for future entries or now blank cells.

=ArrayFormula(IF(A2:A11<>"",A2:A11*E1,""))

enter image description here

How the formula works

The ArrayFormula will apply the calculation cell*E1 in every single row, IF the cell is not empty/blank "".
IF it is a blank cell it will return a blank cell "".

Functions used:

  • ArrayFormula
  • IF
like image 40
marikamitsos Avatar answered Oct 07 '22 13:10

marikamitsos