Copying Excel Formula and controlling relative reference - excel

In Excel I want to copy a formula down and control the relative cell reference.
For example
In A1 if the formula was =B1 and I copied the A1 formula down to A3 the formula in A3 would be =B3. Is there a way of copying the formula in A1 to A3 and have it equal B2?

That's the default copying behaviour in Excel. Did you try it? In fact, if you want to disable it, you have to write $ in front of the fixed row and/or column denominator, so for example $E$1 would be fixed when copied (useful for things that remain constant).
Edit: I think I can imagine what happens: You probably tried to copy the cell contents from the formula editor field. Copy the cell instead, so just mark the cell in the grid by highlighting it, copy it, highlight your target and paste.
Edit2: And please note that you can just drag the little square at the edge of a highlighted cell to apply that cell's formula to an entire area, using the same relative referencing as with copying.

Related

I could not copy same conditional formatting to other cells

For example I created conditional formatting using formula with red, but after I finishing this I copy all the way to the right, selecting cells to apply to ; It worked when I dragged them to the right But it does not work when I drag down.
Here is my formula
Here is my table
So I did this manually I also tried CONTROL+C and PASTE formats
The problem is I changed references on top I do not know starting reference what should be and every time I wanna apply to both rows and columns what formula should I write?
If you have equal spaces between low and high blocks of data, you can use offset inside condition
Select columns E:J
New Rule > Use formula
Type formula: =E1>OFFSET(E1,-7,0) (7 is a distance between each lower and higher cell to check
Set desired color and press ok
Since formula relative so will update for each cell
Your conditional formula has absolute references to the row: E$13 > E$6
But the "Applies to" describes cells all in a single row. So locking the formula to refer to a specific row makes no difference. (If anyone can word a clearer explanation please submit an edit!)
If you change the formulas to E13 > E6 you should be able to copy the formatting across and down your sheet.
Make the formula correct for the first cell in "Applies to", and Excel will apply it to the rest of the range as if you'd copied and pasted it.
So you could probably set a single rule: E11 > E4, and apply it to all the blocks: E11:F13;I11:J13;E17:F19;I17:J19;...

Cell self-reference in Excel

Is there a way to self-reference the cell inside an expression?
For example:
if I want A2 cell to have +1 value in respect of the cell above I write:
=A1+1
If I cut and paste this expression in another cell, it still references to A1.
How to replace that =A1+1 with something like:
=cell.value(this.X,(this.Y-1))+1
UPDATE
Just another use case: create a numbered list (yes, I know excel lines are already numbered, but what about printing?).
Until now I put 1 in A1, =A1+1 in A2 and then dragged A2 lower right corner down to the desired line.
In this way if I delete a row, the following ones become of undefined value.
By putting =OFFSET(A2;-1;0)+1 in A2 and dragging, I can then delete intermediate lines without breaking the sequence.
I guess there are zillions of better/smarter/faster ways of doing this.
use Offset()
so the cell formula would be:
=OFFSET(A1;-1;0)+1
If you copy&paste the actual contents while editing the cell, paste will then put the exact same text into any other cell you select. If you make sure you are not editing the cell, highlight it, copy and then paste into another cell, Excel will automatically update the column and row.
Highlight the cell when not in edit mode, paste into the one below, it will automatically update the row number, =A1+1 will become =A2+1. If you paste it into the cell to the right, it will update the column letter, =A1+1 will become B1+1.
So, for example, if you have the number 9 in cell A1, then enter =A1+1 in cell A2 it will show a value of 10, if you then copy cell A2 (the cell, not the contents) to cell A3, that cell will display the value 11, and contain =A2+1.
If you want to do a long range of cells that add 1 to the previous cell, taking the previous example, highlight cells A2 and A3 then click and hold on the little square at the bottom right of the selection, and drag it as far down column A as you want.

Cell Formula to link to another cell and use that formula

I'd like to create a sheet that has a master formula. From there, I'd like to have a number of lower cells below use the same cell formula but apply it at it's relative position.
For example, in B1 i would write = a1+1.
In b2, I'd like it to apply the b1 formula, so I'd type in a formula to link to b1, but what I really want is the code in that cell, and to have it be relative, so the output would be a2+1.
In b3, id reference b1 but have it return a3+1.
In b4, id reference b1 but have it return a4+1
In b5, id reference b1 but have it return a5+1
This is a very simplified version of what I need. the benefit of doing this is I can change the formula in B1 and have it cascade to all the cells below it. In reality, I can't just drag down because I'm using a template for financial statements on a per market basis. we have dozens of markets and its a pain in the rear to copy/paste them down each time I want to make a simple formula change.
Thanks for any comments. I'd like to do this without VBA if possible. With VBA it gets easy.
Have you considered Named Formulas? If you use relative references in named formulas, then they will be adjusted if the named formula is used in another cell.
For example: Select cell B2, click Formulas > Name Manager > New, enter a name like B2Formula and let it refer to
=Sheet1!A1+1
No $ signs in the cell reference!!!
Now enter this formula into B2:
=B2Formula
Copy the formula down.
Now you decide you need a different formula in B2. So edit the named formula and change it to
=Sheet1!A1*2
and look at the sheet! You only edited one formula, but all the values in column B have adjusted to that new formula
Named Formulas are VERY powerful, especially when used with relative references. Remember that the references will be relative to the cell that is selected when the named formula is defined. Also, when you need to change a named formula with a relative reference, you need to select the same original cell before editing the named formula.

Autofill not working as expected in Excel

I'm using Excel 2003 and I'm trying to autofill a basic formula but it's not working properly for me.
The formula I'm trying to drag accross takes the value in B2 and adds it to the previous cells value. So the value in F10 is E10+B2 etc. I entered it manually for the first 7 cells and then when I try and drag it accross it starts to reference cells C2, D2, E2 etc. when it should just stay B2.
It does this even though I highlighted a group of previous cells where B2 clearly remains the same.
How to get around this?
You need to tell Excel to use an absolute cell. When you copy the formula across, the E10 cell changes to F10, G10 etc. Problem is though, the B2 reference changes to C2, D2 etc. To fix, change it to $B$2 - this will prevent horizontal copying from changing the B. It will also prevent vertical copying from changing the 2.

Excel formula changes when columns are added dynamically

I have a excel workbook where Sheet1 Cell A10 refers to the Sheet2 Cell A1.
I am using the formula
Sheet2!$A$1
I run an SSIS package, which has a script task that adds a column and a row to the Sheet2.
Now the formula automaticlly changes to
Sheet2!$B$2
Although I am using absolute formula, I dont get what I expected. Any ideas on how to achieve what I want?
Please try say =INDIRECT(A11) (adjust A11 to suit) instead of =Sheet2!$A$1 and in A11 (or wherever chosen) =ADDRESS(1,1,1,1,"Sheet2"). I think this should be what you want if I understand you correctly - ie you do not want to follow A1 around as rows/columns are added but literally the top left hand corner, regardless of column/row changes.

Resources