Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Macro to convert some columns to rows

Hi,
I would like to build a macro to convert a table from rows to columns. The
initial spreadsheet is set up so that each row represent one piece of
information for the same ID. For each ID there are 5 rows

A B C
ID1 Name Smith
ID1 Address 22 Smith rd.
ID1 Date of Birth 1987/12/07
ID1 Country of Birth Canada
ID1 Nationality Canadian
ID2 Name Brown
ID2 Address xxBrown st.
ID2 Date of Birth 1965/01/12
ID2 Country of Birth USA
ID2 Nationality Canadian

The new worksheet should display the information by ID while the attributes
listed in column B should be displayed in the Header row (as Column Headings)
ID Name Address Date of Birth Country of Birth
Nationality
ID1 Smith XX Smith rd 1987/12/07 Canada
Canadian
ID2 Brown XX Brown rd 1965/01/12 USA
Canadian


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 846
Default Macro to convert some columns to rows

Don't need a macro - Someone else was kind enough to post this answer
previously (pretty cool). This assumes the information starts in C2 - not
C1 has might be assumed in your example....

=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:C),) in example column "F"
=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:D),) in example column "G"
=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:E),) in example column "H"
=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:F),) in example column "I"
=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:G),) in example column "I"

Copy down as needed - this has been tested and does work.....

--
Wag more, bark less


"T.Vidak" wrote:

Hi,
I would like to build a macro to convert a table from rows to columns. The
initial spreadsheet is set up so that each row represent one piece of
information for the same ID. For each ID there are 5 rows

A B C
ID1 Name Smith
ID1 Address 22 Smith rd.
ID1 Date of Birth 1987/12/07
ID1 Country of Birth Canada
ID1 Nationality Canadian
ID2 Name Brown
ID2 Address xxBrown st.
ID2 Date of Birth 1965/01/12
ID2 Country of Birth USA
ID2 Nationality Canadian

The new worksheet should display the information by ID while the attributes
listed in column B should be displayed in the Header row (as Column Headings)
ID Name Address Date of Birth Country of Birth
Nationality
ID1 Smith XX Smith rd 1987/12/07 Canada
Canadian
ID2 Brown XX Brown rd 1965/01/12 USA
Canadian


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Macro to convert some columns to rows

Hi Brad, thanks this is great and it works but is there a way of adding an
additional function to this formula so that I can be sure I that I am picking
up the right information for the right IDwhen creating the new worksheet?
Thanks...

"Brad" wrote:

Don't need a macro - Someone else was kind enough to post this answer
previously (pretty cool). This assumes the information starts in C2 - not
C1 has might be assumed in your example....

=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:C),) in example column "F"
=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:D),) in example column "G"
=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:E),) in example column "H"
=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:F),) in example column "I"
=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:G),) in example column "I"

Copy down as needed - this has been tested and does work.....

--
Wag more, bark less


"T.Vidak" wrote:

Hi,
I would like to build a macro to convert a table from rows to columns. The
initial spreadsheet is set up so that each row represent one piece of
information for the same ID. For each ID there are 5 rows

A B C
ID1 Name Smith
ID1 Address 22 Smith rd.
ID1 Date of Birth 1987/12/07
ID1 Country of Birth Canada
ID1 Nationality Canadian
ID2 Name Brown
ID2 Address xxBrown st.
ID2 Date of Birth 1965/01/12
ID2 Country of Birth USA
ID2 Nationality Canadian

The new worksheet should display the information by ID while the attributes
listed in column B should be displayed in the Header row (as Column Headings)
ID Name Address Date of Birth Country of Birth
Nationality
ID1 Smith XX Smith rd 1987/12/07 Canada
Canadian
ID2 Brown XX Brown rd 1965/01/12 USA
Canadian


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 846
Default Macro to convert some columns to rows

Yes, using basically same formula as before
=OFFSET($A$1,ROWS($2:2)*5-5+COLUMNS(A:$A),)
Will get you what you need - there are other ways to do this but this would
be consistent with what you have....
--
Wag more, bark less


"T.Vidak" wrote:

Hi Brad, thanks this is great and it works but is there a way of adding an
additional function to this formula so that I can be sure I that I am picking
up the right information for the right IDwhen creating the new worksheet?
Thanks...

"Brad" wrote:

Don't need a macro - Someone else was kind enough to post this answer
previously (pretty cool). This assumes the information starts in C2 - not
C1 has might be assumed in your example....

=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:C),) in example column "F"
=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:D),) in example column "G"
=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:E),) in example column "H"
=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:F),) in example column "I"
=OFFSET($C$1,ROWS($2:2)*5-5+COLUMNS($C:G),) in example column "I"

Copy down as needed - this has been tested and does work.....

--
Wag more, bark less


"T.Vidak" wrote:

Hi,
I would like to build a macro to convert a table from rows to columns. The
initial spreadsheet is set up so that each row represent one piece of
information for the same ID. For each ID there are 5 rows

A B C
ID1 Name Smith
ID1 Address 22 Smith rd.
ID1 Date of Birth 1987/12/07
ID1 Country of Birth Canada
ID1 Nationality Canadian
ID2 Name Brown
ID2 Address xxBrown st.
ID2 Date of Birth 1965/01/12
ID2 Country of Birth USA
ID2 Nationality Canadian

The new worksheet should display the information by ID while the attributes
listed in column B should be displayed in the Header row (as Column Headings)
ID Name Address Date of Birth Country of Birth
Nationality
ID1 Smith XX Smith rd 1987/12/07 Canada
Canadian
ID2 Brown XX Brown rd 1965/01/12 USA
Canadian


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert columns to rows DHM Excel Worksheet Functions 4 June 30th 07 02:52 AM
Convert rows to columns lucrezia Excel Worksheet Functions 0 June 28th 07 06:36 PM
Convert columns to rows KT Excel Worksheet Functions 1 October 8th 06 02:10 PM
to convert columns to rows having mulit independent group columns Quacy Excel Worksheet Functions 1 August 22nd 06 11:20 PM
Convert rows to columns Geno Excel Worksheet Functions 0 July 6th 06 04:41 PM


All times are GMT +1. The time now is 05:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"