Transpose formula's ??

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Transpose formula's ??

Post by VegasNath »

Is it possible to drag a formula across columns, transposing the original data? EG:

In cell A1
=Detail!A1
... drag to E1, with the results A1:A5
:wales: Nathan :uk:
There's no place like home.....

User avatar
mbarron
2StarLounger
Posts: 112
Joined: 25 Jan 2010, 20:19

Re: Transpose formula's ??

Post by mbarron »

You can use the OFFSET function:
=OFFSET(Details!$A$1,COLUMN()-1,0)

or the INDEX function:
=INDEX(Details!$A:$A,COLUMN())
Last edited by mbarron on 01 Jul 2010, 18:27, edited 1 time in total.

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Transpose formula's ??

Post by HansV »

Select A1:E1.
Enter the formula

=TRANSPOSE(Detail!A1:A5)

Press Ctrl+Shift+Enter to save it as an array formula.
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Transpose formula's ??

Post by VegasNath »

The offset does the trick, Thanks Mike.

Hans: I need to be able to copy the formula across columns, so the Transpose array will not work for me. Thanks.
:wales: Nathan :uk:
There's no place like home.....

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Transpose formula's ??

Post by VegasNath »

VegasNath wrote:The offset does the trick, Thanks Mike.
My only problem with this is that every formula across the column is identical, but all produce different results (as expected). It works, but I don't understand it. :scratch: It's difficult to understand the audit trail.
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Transpose formula's ??

Post by HansV »

COLUMN() returns the column number of the cell containing the formula: 1 for column A, 2 for column B, etc.
COLUMN()-1 is 1 less than the column number.
OFFSET(Details!$A$1,COLUMN()-1,0) starts at A1 on Detail(s) and moves COLUMN()-1 rows down, 0 columns to the right. So the result depends on the column number of the cell containing the formula.
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Transpose formula's ??

Post by VegasNath »

HansV wrote:COLUMN() returns the column number of the cell containing the formula: 1 for column A, 2 for column B, etc.
COLUMN()-1 is 1 less than the column number.
OFFSET(Details!$A$1,COLUMN()-1,0) starts at A1 on Detail(s) and moves COLUMN()-1 rows down, 0 columns to the right. So the result depends on the column number of the cell containing the formula.
Thankyou for the explanation Hans, I think I understand it, even if I still find it a little confusing...

How can I eliminate the #VALUE! from this?

=(OFFSET('5.19'!$V4,COLUMN()-3,0)/Unit)+(OFFSET('5.19'!$W4,COLUMN()-3,0)/Unit)

something along the lines of...

=IF(ISERROR(OFFSET('5.19'!$V4,COLUMN()-3,0)/Unit)+(OFFSET('5.19'!$W4,COLUMN()-3,0)/Unit)=TRUE,0,OFFSET('5.19'!$V4,COLUMN()-3,0)/Unit)+(OFFSET('5.19'!$W4,COLUMN()-3,0)/Unit)

I am trying to sum columns V&W, dragging the formula accross columns, which will alter to the relevant row from the source sheet. Some of which will populate #VALUE! which I want to ignore. Hope this makes sense. Thanks
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Transpose formula's ??

Post by HansV »

Try

=IF(ISERROR(OFFSET('5.19'!$V4,COLUMN()-3,0)+OFFSET('5.19'!$W4,COLUMN()-3,0)),0,(OFFSET('5.19'!$V4,COLUMN()-3,0)+OFFSET('5.19'!$W4,COLUMN()-3,0))/Unit)

In Excel 2007 or later, you can use

=IFERROR((OFFSET('5.19'!$V4,COLUMN()-3,0)+OFFSET('5.19'!$W4,COLUMN()-3,0))/Unit,0)
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Transpose formula's ??

Post by VegasNath »

Thanks.

The 2007 version is a vast improvement!
:wales: Nathan :uk:
There's no place like home.....