I want to drag down a column but keep the same row of data by going into the next column on another sheet.
For example I have sheet1 with random data in row cells: A1 B1 C1 D1.
On sheet 2 I want to copy this row of data into a column for example: C3 C4 C5 C6.
I have tried used =OFFSET('sheet1'!$A$1,0,1) but this just keeps giving the data on cell B1.
How do I drag down the cells (autofill), but change the column letter and keep the same row number from another sheet?
Try,
=INDEX(Sheet1!$1:$1, 1, ROW(1:1))
Drag down as required. Here it is on a single worksheet.
Your formula would have worked as,
=OFFSET('sheet1'!$A$1, 0, ROW(1:1)-1)
But the OFFSET function is volatile¹ and best avoided if possible.
¹ Volatile functions recalculate whenever anything in the entire workbook changes, not just when something that affects their outcome changes. Examples of volatile functions are INDIRECT, OFFSET, TODAY, NOW, RAND and RANDBETWEEN. Some sub-functions of the CELL and INFO worksheet functions will make them volatile as well.
It sounds like you have to transpose() the data as Milind suggested because transpose should keep the formulas "intact" and simply reference the new positions of the cells rather than the old.
The easiest way to do this is to select the entire range of data, right click where you want the new data set to start (C3), then click
Paste Special
Transpose
You can use the Transpose() function in your target cells i.e. C3,C4,C5,C6.
This link shows the procedure in detail
Related
I am looking for a way to accomplish the following using spreadsheet formulae: the output in cell D5 should be the array from cell B5 to the last populated cell (assume the range is contiguous). Thus if text were typed into cell B10, the output would automatically expand.
However, I want to avoid the volatile OFFSET and INDIRECT functions.
So I have this formula in cell D5:
=UPPER(B5:INDEX(B:B,ROW(B5)+COUNTA(B5:INDEX(B:B,ROWS(B:B),,1))-1))
but this is unsatisfactory as it references the B:B column.
In effect I want a construction that returns me B:B given the cell B5 ie the equivalent of =INDIRECT("C" & COLUMN(B5),"FALSE"), but in a non-volatile format.
Any suggestions?
NB. I don't have the very latest Excel. I have LET, SEQUENCE, FILTER etc, but not LAMBDA and the functions that came with it (ie I can't do recursive LAMBDA calls).
Make column B data into a table
the content of cell D5 can then be dragged to a different location, without the formula results changing.
In cell B2, I have the following formula
=VLOOKUP($A2,Sheet1!A:B,2,0)
Now if I autofill to the right in cell C2, the formula becomes
=VLOOKUP($A2,Sheet1!B:C,2,0)
but I would like it to become
=VLOOKUP($A2,Sheet1!C:D,2,0) i.e. C:D instead of B:C (two step increment)
and so forth with
=VLOOKUP($A2,Sheet1!E:F,2,0)
in cell D2 and etcetera up to more or less 3000 columns.
How could this be achieved? A VBA macro would be fine, but I'd prefer not to use a macro if possible.
Use the non Volatile INDEX()
=VLOOKUP($A2,INDEX(Sheet1!$A:$HZZ,1,(COLUMN(A:A)-1)*2+1):INDEX(Sheet1!$A:$HZZ,1040000,(COLUMN(A:A)-1)*2+2),2,FALSE)
You can use OFFSET for this:
=VLOOKUP($A2, OFFSET(Sheet1!$A:$B, 0, 2*(Column()-2)), 2, FALSE)
This will start with the target range $A:$B, then move it down 0 rows and across 2*(Column()-2) columns. For B/C/D this will be 0/2/4 columns
I want to reference the worksheet name and then transpose the totals in row 1 to a column in my summary worksheet.
I have found the following formula, which looks up a worksheet and takes the total, then I can paste this down to look up the row, essentially transposing row H1 to AG1 to column B on my summary worksheet.
=INDEX('201510'!$H$1:$AG$1,ROWS(B$1:B1))
Now I want to replace the direct ref to the worksheet tab to a lookup. So when I type the worksheet name in say row 2, it will give me the monthly totals.
This formula looks up the tab reference in B2 and displays the contents of H1. Where B2 has the worksheet name.
=INDIRECT("'"&$B$2&"'!$H1")
However when I copy this formula down the column, H1 does not change to H2. Furthermore, I need it to transpose vertically to I1.
How can I combine the two formulae?
Thanks,
Andy
You will need to combine the logic of an INDIRECT function with regular Excel referencing. Note that in your final formula, the "'!$H1" is text, meaning Excel doesn't try to compute it until it calculates the value of the cell. ie: it does not compute that what you are typing is a reference, just text.
So, assuming you continue to use the INDIRECT function, you will need to create the address of the final portion dynamically. There are many ways to do this. For example:
=INDIRECT("'"&$B$2&"'!H"&ROW()-1)
This version takes the string of the sheet name from B2, and then adds on the "'!H" as an additional string, and then takes the row as the current row number of the cell above the cell the formula is in. ie: if this formula is in D2, it will look up H1 on the other sheet. This method relies on your formula being in a consistent position within your sheet - if you insert a row above this one, it will change what ROW() calculates as, thus changing the formula.
Another method would be to reference H1 in a way that consistently points there, and also iterates into higher numbers as you drag down the formula. This method may be more useful for your purposes, as it also teaches another function:
=INDIRECT(ADDRESS(ROW(H1),COLUMN(H1),,1,$B$2))
Note that the ADDRESS function creates a string which shows the way a direct reference to a specific cell would. with the arguments I have above, it picks up the row number of H1 [iterating down, as there are no $ in front of the 1], the column number of H1 [iterating to the right, as there is no $ in front of the H], and the sheet name from $B$2.
As the title suggests, I have a column in my first worksheet which gets its data from another column, in a second spreadsheet.
I have linked them using ='Data'!B1
Of course, if I drag the handle down, I get all the remaining data from the linked column, but I would like to have an empty row after each cell.
Like so: B1 has data, B2 is blank, B3 has data, B4 is blank, etc.
If some kind person out there could help me out, I would appreciate it very much. I have tried macros and looked this up in forums but can't seem to make this work with Data --> Sort.
Thank you! :)
Given what you're asking for, the way I would do it would be using the Offset or Indirect function so I can control which cells to pull in from the other sheet.
Given your example, in Sheet1, I would have:
B1: =OFFSET(Sheet2!$B$1,(ROW(B1)-1)/2,0)
B2: <blank>
B3: =OFFSET(Sheet2!$B$1,(ROW(B3)-1)/2,0)
B4: <blank>
You can drag this down and it will give you alternating formula / blanks and pull the consecutive row from the other sheet.
As a quick explation, the function will always look at cell B1 in your second sheet and offset it by (Row()-1)/2 rows... So, in row 1, it would offset it by (1-1)/2 = 0 rows, in row 3, it would offset it by (3-1)/2 = 1 rows, etc.
Hope this makes sense and does the trick!!
I have 2 sheets in my spreadsheet. Sheet2 pulls information from Sheet1. In sheet2, there are 2 columns. Column A has company names. Column B has a formula which searches for the company name of that row within sheet1, and sums the values from that row in sheet1.
I have been able to achieve this with the following formula.
=SUMPRODUCT((Sheet1!B:B=A1)*(Sheet1!F:F))
This works fine, however I have to manually type "A1" into the formula. For the other rows, I would have to write B1, C1, D1 etc.
I have searched for how to reference the cell to the left, and I found this formula...
=OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())), 0, -1)
This seems to work as a standalone formula in a cell, but I cannot figure out how to incorporate this into the SUMPRODUCT formula. Anything I try gives errors. I need something like this.
=SUMPRODUCT((Sheet1!B:B=(=OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())), 0, -1)))*(Sheet1!F:F))
As per pnuts' suggestion to make it an answer:
The answer is just to drag the formula around. Just make sure to fix (either use F4 or add dollar signs) your range if it is not an entire column or an entire row