Help with OFFSET

EvansB2

Board Regular
Joined
Nov 25, 2008
Messages
245
Office Version
  1. 365
Platform
  1. Windows
Hi there,

I have a table below that consists of a list of projects in column A and on each row values are input representing year on year costs. I would like to put Table 1 in a list format as shown in Table 2. These are examples and the reality is that I have a lot of data to re-format and I'm thinking that an OFFSET formula would assist in this?

Table 1

[TABLE="width: 286"]
<colgroup><col width="29" style="width: 22pt; mso-width-source: userset; mso-width-alt: 1060;"> <col width="58" style="width: 44pt; mso-width-source: userset; mso-width-alt: 2121;" span="6"> <tbody>[TR]
[TD="width: 29, bgcolor: transparent"] [/TD]
[TD="width: 58, bgcolor: #D9D9D9"]A[/TD]
[TD="width: 58, bgcolor: #D9D9D9"]B[/TD]
[TD="width: 58, bgcolor: #D9D9D9"]C[/TD]
[TD="width: 58, bgcolor: #D9D9D9"]D[/TD]
[TD="width: 58, bgcolor: #D9D9D9"]E[/TD]
[TD="width: 58, bgcolor: #D9D9D9"]F[/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]1[/TD]
[TD="width: 58, bgcolor: #B4C6E7"]Project[/TD]
[TD="width: 58, bgcolor: #B4C6E7"]Year 1[/TD]
[TD="width: 58, bgcolor: #B4C6E7"]Year 2[/TD]
[TD="width: 58, bgcolor: #B4C6E7"]Year 3[/TD]
[TD="width: 58, bgcolor: #B4C6E7"]Year 4[/TD]
[TD="width: 58, bgcolor: #B4C6E7"]Year 5[/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]2[/TD]
[TD="bgcolor: transparent"]A[/TD]
[TD="bgcolor: transparent"]£500[/TD]
[TD="bgcolor: transparent"]£100[/TD]
[TD="bgcolor: transparent"]£300[/TD]
[TD="bgcolor: transparent"]£0[/TD]
[TD="bgcolor: transparent"]£500[/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]3[/TD]
[TD="bgcolor: transparent"]B[/TD]
[TD="bgcolor: transparent"]£0[/TD]
[TD="bgcolor: transparent"]£200[/TD]
[TD="bgcolor: transparent"]£300[/TD]
[TD="bgcolor: transparent"]£600[/TD]
[TD="bgcolor: transparent"]£0[/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]4[/TD]
[TD="bgcolor: transparent"]C[/TD]
[TD="bgcolor: transparent"]£0[/TD]
[TD="bgcolor: transparent"]£0[/TD]
[TD="bgcolor: transparent"]£450[/TD]
[TD="bgcolor: transparent"]£450[/TD]
[TD="bgcolor: transparent"]£800[/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]5[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]6[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]7[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
</tbody>[/TABLE]

Table 2
[TABLE="width: 286"]
<colgroup><col width="29" style="width: 22pt; mso-width-source: userset; mso-width-alt: 1060;"> <col width="58" style="width: 44pt; mso-width-source: userset; mso-width-alt: 2121;" span="6"> <tbody>[TR]
[TD="width: 29, bgcolor: transparent"] [/TD]
[TD="width: 58, bgcolor: #D9D9D9"]A[/TD]
[TD="width: 58, bgcolor: #D9D9D9"]B[/TD]
[TD="width: 58, bgcolor: #D9D9D9"]C[/TD]
[TD="width: 58, bgcolor: #D9D9D9"]D[/TD]
[TD="width: 58, bgcolor: #D9D9D9"]E[/TD]
[TD="width: 58, bgcolor: #D9D9D9"]F[/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]1[/TD]
[TD="width: 58, bgcolor: #B4C6E7"]Project[/TD]
[TD="width: 58, bgcolor: #B4C6E7"]Year [/TD]
[TD="width: 58, bgcolor: #B4C6E7"]Value[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]2[/TD]
[TD="bgcolor: transparent"]A[/TD]
[TD="bgcolor: transparent"]1[/TD]
[TD="bgcolor: transparent"]£500[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]3[/TD]
[TD="bgcolor: transparent"]A[/TD]
[TD="bgcolor: transparent"]2[/TD]
[TD="bgcolor: transparent"]£100[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]4[/TD]
[TD="bgcolor: transparent"]A[/TD]
[TD="bgcolor: transparent"]3[/TD]
[TD="bgcolor: transparent"]£300[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]5[/TD]
[TD="bgcolor: transparent"]A[/TD]
[TD="bgcolor: transparent"]4[/TD]
[TD="bgcolor: transparent"]£0[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]6[/TD]
[TD="bgcolor: transparent"]A[/TD]
[TD="bgcolor: transparent"]5[/TD]
[TD="bgcolor: transparent"]£500[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: #D9D9D9"]7[/TD]
[TD="bgcolor: transparent"]B[/TD]
[TD="bgcolor: transparent"]1[/TD]
[TD="bgcolor: transparent"]£0[/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
</tbody>[/TABLE]


Any help would be appreciated.

Regards

Ben
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Heres one way. I put Table 1 in A1:F4 of Sheet1 and the headers of Table 2 in A1:C1 of Sheet2. Then in Sheet2 A2,B2,C2 i placed these 3 formulas:

=INDEX(Sheet1!$A:$A,CEILING((ROW()-1)/(MATCH("zzz",Sheet1!$1:$1)-1),1)+1)
=MOD(ROW()+MATCH("zzz",Sheet1!$1:$1)-3,(MATCH("zzz",Sheet1!$1:$1)-1))+1
=INDEX(Sheet1!$A$1:$Z$1000,MATCH(A2,Sheet1!$A$1:$A$1000,0),MATCH("Year "&B2,Sheet1!$A$1:$Z$1,0))

They work for 1000 rows and 26 columns in Table 1. Drag down until the results start to error.
 
Last edited:
Upvote 0
Thanks for quick reply Steve,

Can you tell me what the "zzz" means?

Regards

Ben
 
Upvote 0
Ok.

I have applied formulas and in Sheet2 columns A & B work great, however in col C it returs "#N/A". I have double checked and nothing is amiss.

Can you think of any obvious errors I may have made?

Regards

Ben
 
Upvote 0
another option is PowerQuery
(PQ add-in - Excel 2010/2013, built-in - Excel 2016 and higher)

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td]Source[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]Result[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]Project[/td][td=bgcolor:#5B9BD5]Year 1[/td][td=bgcolor:#5B9BD5]Year 2[/td][td=bgcolor:#5B9BD5]Year 3[/td][td=bgcolor:#5B9BD5]Year 4[/td][td=bgcolor:#5B9BD5]Year 5[/td][td][/td][td=bgcolor:#70AD47]Project[/td][td=bgcolor:#70AD47]Year[/td][td=bgcolor:#70AD47]Value[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]A[/td][td=bgcolor:#DDEBF7]
500​
[/td][td=bgcolor:#DDEBF7]
100​
[/td][td=bgcolor:#DDEBF7]
300​
[/td][td=bgcolor:#DDEBF7]
0​
[/td][td=bgcolor:#DDEBF7]
500​
[/td][td][/td][td=bgcolor:#E2EFDA]A[/td][td=bgcolor:#E2EFDA]1[/td][td=bgcolor:#E2EFDA]
500​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]B[/td][td]
0​
[/td][td]
200​
[/td][td]
300​
[/td][td]
600​
[/td][td]
0​
[/td][td][/td][td]A[/td][td]2[/td][td]
100​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]C[/td][td=bgcolor:#DDEBF7]
0​
[/td][td=bgcolor:#DDEBF7]
0​
[/td][td=bgcolor:#DDEBF7]
450​
[/td][td=bgcolor:#DDEBF7]
450​
[/td][td=bgcolor:#DDEBF7]
800​
[/td][td][/td][td=bgcolor:#E2EFDA]A[/td][td=bgcolor:#E2EFDA]3[/td][td=bgcolor:#E2EFDA]
300​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]A[/td][td]4[/td][td]
0​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td=bgcolor:#E2EFDA]A[/td][td=bgcolor:#E2EFDA]5[/td][td=bgcolor:#E2EFDA]
500​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]B[/td][td]1[/td][td]
0​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td=bgcolor:#E2EFDA]B[/td][td=bgcolor:#E2EFDA]2[/td][td=bgcolor:#E2EFDA]
200​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]B[/td][td]3[/td][td]
300​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td=bgcolor:#E2EFDA]B[/td][td=bgcolor:#E2EFDA]4[/td][td=bgcolor:#E2EFDA]
600​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]B[/td][td]5[/td][td]
0​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td=bgcolor:#E2EFDA]C[/td][td=bgcolor:#E2EFDA]1[/td][td=bgcolor:#E2EFDA]
0​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]C[/td][td]2[/td][td]
0​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td=bgcolor:#E2EFDA]C[/td][td=bgcolor:#E2EFDA]3[/td][td=bgcolor:#E2EFDA]
450​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]C[/td][td]4[/td][td]
450​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td=bgcolor:#E2EFDA]C[/td][td=bgcolor:#E2EFDA]5[/td][td=bgcolor:#E2EFDA]
800​
[/td][/tr]
[/table]


Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Project"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(Table.ReplaceValue(#"Unpivoted Other Columns","Year ","",Replacer.ReplaceText,{"Attribute"}),{{"Attribute", "Year"}})
in
    #"Renamed Columns"[/SIZE]
 
Upvote 0
Ok.

I have applied formulas and in Sheet2 columns A & B work great, however in col C it returs "#N/A". I have double checked and nothing is amiss.

Can you think of any obvious errors I may have made?




Regards

Ben

What does this produce?


=MATCH("Year "&B2,Sheet1!$A$1:$Z$1,0)
 
Upvote 0
Steve, my mistake, I didn't have a space between thesecond exclamation mark, i.e. "Year".

All sorted. Thanks again.

Ben
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,280
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top