Drag down formula and change COLUMN references instead of ROWS - excel

I have this formula in Excel, in row E5:
=SUM(Banco!H$5;Banco!H$6;Banco!H$8;Banco!H$9;Banco!H$10;Banco!H$11)
I need it to change the COLUMN references instead of ROWS when I drag it down (basically behave like I was dragging it across)... For example:
=SUM(Banco!I$5;Banco!I$6;Banco!I$8;Banco!I$9;Banco!I$10;Banco!I$11)
=SUM(Banco!J$5;Banco!J$6;Banco!J$8;Banco!J$9;Banco!J$10;Banco!J$11)
=SUM(Banco!K$5;Banco!K$6;Banco!K$8;Banco!K$9;Banco!K$10;Banco!K$11)
Any clues?
Thanks a lot!

... Use the offset function.
For example - Suppose you had a formula in row 1 and you wanted to reference Banco!H5, you could do something like:
=OFFSET(Banco!$G$5,0,ROW())
Now, as you drag it down, it will offset by the number of rows down you go.
So your new formula would look as follows:
=SUM(OFFSET(Banco!$G$5,0,ROW()),OFFSET(Banco!$G$6,0,ROW()),OFFSET(Banco!$G$8,0,ROW()),OFFSET(Banco!$G$9,0,ROW()),OFFSET(Banco!$G$10,0,ROW()),OFFSET(Banco!$G$11,0,ROW()))
Again, this assumes you are pasting this formula in row 1 (I know it's ugly, but you specified specific cells, so you have to specify each one separately)
Hope this makes sense

Use a combination of the OFFSET and the COUNTA function. The OFFSET function will give the offset of COUNTA columns each time you go down a row. Make the counta function count the number of rows above the row that you're dragging the entire function into (aka each time you drag the function to an extra row, it will add 1)

Related

Incrementing excel formula by two

I have an excel sheet with the following formula:
=('Forecast Workings'!T2+'Forecast Workings'!T3)/1000-4.6
=('Forecast Workings'!T4+'Forecast Workings'!T5)/1000-4.6
=('Forecast Workings'!T6+'Forecast Workings'!T7)/1000-4.6
How can I write this formula so that I can simply drag this down to fill in the rest of the values and that I get the value to increment by 2 each time?
If your initial cell is in first row and you want to multiply you could use:
=(INDIRECT("Forecast Workings!T"&ROW()*2)+INDIRECT("Forecast Workings!T"&ROW()*2+1))/1000-4.6
Subtract value from ROW() if you are not in the first row.
try,
=sum(index('Forecast Workings'!T:T, (row(1:1)-1)*2+2),
index('Forecast Workings'!T:T, (row(1:1)-1)*2+3))/1000-4.6
You will need a helper column, or use indirect and then use a mathematical approach on the formula row() to get the right return. as an example if you start this in row 2 and drag down this will increment by two. (assuming row one are titles)
=INDIRECT("'Forecast Workings'!T" & (ROW()-1)*2)+INDIRECT("'Forecast Workings'!T" & ((ROW()-1)*2)+1)/1000-4.6
I would also advise to check out the code of conduct, you would need to show what you have tried to solve this yourself and what did not work.

Automatically increment sheet reference when dragging formula

I have a formula with the following syntax:
=SheetName!E10
and need some way to drag the formula and change just the sheet name as it moves to the right. So the E10 part needs to stay the same with the sheet number incrementing as I drag the formula. We have many rows and columns to do and this would definitely speed us up.
Is this possible?
So the result would look like this:
=Sheet1!E10 =Sheet2!E10 =Sheet3!E10
This is the result:
from applying this formula:
=INDIRECT("mo"&COLUMN()+0&"!B4")
Please try:
=INDIRECT("Sheet"&COLUMN()+x&"!E10")
where x is the offset to return the appropriate number ( Column()+x ) for wherever you choose to place the formula.
Edit to match subsequent details from the image (where 5 may be in ColumnB) and a comment, perhaps should be:
=INDIRECT("mo"&COLUMN()-1&"!E10")

Proper Use of the Offset Function

I have the following formula
=IFERROR(IF(FIND(OFFSET($B$2,1,0),$A3,1),VLOOKUP(OFFSET($B$2,1,0),'Keyword list'!B2:E316533,2,FALSE),""),"n/a")
which looks up a value associated with a word if the word is found and otherwise returns "n/a". I have included the OFFSET() function with the hope of making it so that when I move the formula to another column, say from column B to column C, the reference is not still $B$2, and not C2, but B3. Effectively I am trying to make it so that when the formula is dragged across the reference row changes instead of the column, and when I drag down the reference remains fixed at $B$2, $B$3 and so on. Is it possible to use the offset function to do this? Is there a clear mistake I've made in trying to apply it to the above formula? Thanks!
You could maybe try the following?
=IFERROR(IF(FIND(OFFSET($B$2,COLUMNS($A:A)-1,0),$A3,1),
VLOOKUP(OFFSET($B$2,COLUMNS($A:A)-1,0),'Keyword list'!$B$2:$E$31,2,FALSE),""),
"n/a")
I made a google spreadsheet so that you can try to drag the formula across.
The limitation of that formula is that it will rely on the column of the formula, and it cannot be dragged towards the left in Excel, since that will cause the reference COLUMNS($A:A) to go COLUMNS(#REF!). It can be put in any column then dragged to the right.
This is untested, but I think it does what you want, i.e., shift the reference down one row, for each column you drag to the right. It uses the COLUMNS function anchored at B in one half and relative in another:
=IFERROR(IF(FIND(OFFSET($B$2,COLUMNS($B:B),1),$A3,1),VLOOKUP(OFFSET($B$2,COLUMNS($B:B),1),'Keyword list'!B2:E316533,2,FALSE),""),"n/a")
I'd go with using INDIRECT to build a reference out of a computed string.
INDIRECT("B"&(2+COLUMN(<current cell>)-COLUMN($B$1)))
This way your reference gets calculated dependent from the offset to column B:
In cell D2 the referenced cell is "B"&(2+COLUMN(D2)-COLUMN($B$1)) = "B"&(2+4-2) = "B4"
In cell D3 the reference does not change, as only columns are taken into account.
Same for cell E2: "B"&(2+COLUMN(E2)-COLUMN($B$1)) = "B"&(2+5-2) = "B5"
If your calculation is that fixed, you could even only do with COLUMN(E2) as 2 and COLUMN(B1) cancel each other out: INDIRECT("B"&COLUMN(<current cell>)))

offset in excel referencing the wrong cell?

I'm trying to use offset to link two sheets in a work book
I am in Sheet2
If I type ='Sheet1'!B6 .... it gives me B6 from Sheet1
If I type +OFFSET('Sheet1'!B6,0,ROW()).... it gives me L6 from Sheet1
Why does it not pick up B6?
If I drag down the second formula it gives me M6,N6,O6,P6 etc, so it's at least consistent.
I've tried everything I can think of to get it to refer to the proper cell but to no avail. It's frustrating as I could have typed the data in by now!
Try
=OFFSET('Sheet1'!B6,0,0)
The "Row()" function is returning a value that is pushing the Offset 11 columns to the right.
Your mistake is you have ROW() in place of column argument ? The 3rd argument in OFFSET is column number and not row number.
Try :
=OFFSET(Sheet1!B6,0,0)
In OFFSET, 0 Row and 0 column means it is the same co-ordinate as the current referenced cell. That is, from Sheet1!B6 increase/decrease 0 rows & 0 columns.
I Have found a solution!!
If I create another column say B in Sheet2 and fill it with 1,2,3,4 etc.I can use the formula like this:-
=OFFSET('Outside funds'!$B$6,0,(B10-1))
It picks up everything correctly.
It may not be the best solution but it works.
Thanks for your help.
To transpose columns to rows, try
=OFFSET('Sheet1'!$B$6,0,ROW()-1)
The second offset parameter is the row offset, the third is the column offset. Make sure to anchor the first parameter otherwise you'll double the offset when you copy down.

what is the purpose of OFFSET in excel?

In Excel, the Offset function returns a reference to a range that is offset a number of rows and columns from another range or cell.
can someone please tell me what that means?
for example in this formula:
=OFFSET($B$4,ROW()-ROW($F$4),0,1,1)
what is it doing?
The purpose of OFFSET(BASE, ROW-OFFSET, COLUMN-OFFSET, NUM-ROWS, NUM-COLUMNS) is to select the content of cells that are NUM-ROWS rows and NUM-COLUMS distant from the base cell. If the selected cells are just one, then the content of that cell will be used as result, otherwise the result will be an array that can be passed to functions as SUM.
In your example, the function is simply selecting the content of the cell B4.
That example formula is odd, because it references a cell to get the row then takes that away from the current row - this bit ROW()-ROW($F$4, which might as well be row()-4, but there you go.
Offset, works like this
A cell location to start at, how many rows away from this, cols away from the this, optional size(rows), optional size(cols).

Resources