Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions,microsoft.public.access
external usenet poster
 
Posts: 12
Default How do I group and transpose data - macro help needed.

I have a MS Excel table comprising 2 columns and 6500 rows. Column A
contains 366 variables, (VA001 - VA336), and Column B contains 48, (VB01 -
VB48), the AB pairings are unique but not all possible pairings are present.
This table is created monthly and is variable.

I want to be able to sort by Column A then Column B.

I then want to identify all VA001 rows and copy the corresponding Column B
entries then Transpose these to the top VA001 row and delete all VA001 rows
bar the top one with the transposed Column B data so that I end up with a
single row for VA001 that is as many columns wide as is necessary to
accommodate the variable number of corresponding Column B entries.

I want to repeat this for each Column A variable so that I end up with a
table with 366 rows + header with as many columns as is necessary to
accommodate the longest row of former Colum B data however long that might
be.

I then need to apply the same to other similar tables that have different
numbers of variables for A and B.

I can do all of this manually but it is tedious.

What would a macro to do this look like?

Can I use the same macro in both MS Excel and MS Access?

TIA.

Chris


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions,microsoft.public.access
external usenet poster
 
Posts: 1,240
Default How do I group and transpose data - macro help needed.

Chris Mitchell wrote:
I have a MS Excel table comprising 2 columns and 6500 rows. Column A
contains 366 variables, (VA001 - VA336), and Column B contains 48, (VB01 -
VB48), the AB pairings are unique but not all possible pairings are present.
This table is created monthly and is variable.

I want to be able to sort by Column A then Column B.

I then want to identify all VA001 rows and copy the corresponding Column B
entries then Transpose these to the top VA001 row and delete all VA001 rows
bar the top one with the transposed Column B data so that I end up with a
single row for VA001 that is as many columns wide as is necessary to
accommodate the variable number of corresponding Column B entries.

I want to repeat this for each Column A variable so that I end up with a
table with 366 rows + header with as many columns as is necessary to
accommodate the longest row of former Colum B data however long that might
be.

I then need to apply the same to other similar tables that have different
numbers of variables for A and B.

I can do all of this manually but it is tedious.

What would a macro to do this look like?

Can I use the same macro in both MS Excel and MS Access?

TIA.

Chris



Without a macro...sort by Column A and Column B. Assuming you have headers in
Row 1, put the following in C2 and copy down as needed:

=IF(COUNTIF($A$2:$A2,$A2)=1,B2,"")

And put this in D2 and copy across and down as needed:

=IF(COUNTIF($A$2:$A2,$A2)=1,IF(INDIRECT("A"&ROW()+ COLUMN()-3)=$A2,INDIRECT("B"&ROW()+COLUMN()-3),""),"")

Select columns C:AX (or as far as you needed to go) and COPY / PASTE SPECIAL /
VALUES.

Sort by Column C and delete any rows where there is no entry in C. Then delete
Column B and sort by Column A.
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions,microsoft.public.access
external usenet poster
 
Posts: 1,240
Default How do I group and transpose data - macro help needed.

Glenn wrote:
Chris Mitchell wrote:
I have a MS Excel table comprising 2 columns and 6500 rows. Column A
contains 366 variables, (VA001 - VA336), and Column B contains 48,
(VB01 - VB48), the AB pairings are unique but not all possible
pairings are present. This table is created monthly and is variable.

I want to be able to sort by Column A then Column B.

I then want to identify all VA001 rows and copy the corresponding
Column B entries then Transpose these to the top VA001 row and delete
all VA001 rows bar the top one with the transposed Column B data so
that I end up with a single row for VA001 that is as many columns wide
as is necessary to accommodate the variable number of corresponding
Column B entries.

I want to repeat this for each Column A variable so that I end up with
a table with 366 rows + header with as many columns as is necessary to
accommodate the longest row of former Colum B data however long that
might be.

I then need to apply the same to other similar tables that have
different numbers of variables for A and B.

I can do all of this manually but it is tedious.

What would a macro to do this look like?

Can I use the same macro in both MS Excel and MS Access?

TIA.

Chris


Without a macro...sort by Column A and Column B. Assuming you have
headers in Row 1, put the following in C2 and copy down as needed:

=IF(COUNTIF($A$2:$A2,$A2)=1,B2,"")

And put this in D2 and copy across and down as needed:

=IF(COUNTIF($A$2:$A2,$A2)=1,IF(INDIRECT("A"&ROW()+ COLUMN()-3)=$A2,INDIRECT("B"&ROW()+COLUMN()-3),""),"")


Select columns C:AX (or as far as you needed to go) and COPY / PASTE
SPECIAL / VALUES.

Sort by Column C and delete any rows where there is no entry in C. Then
delete Column B and sort by Column A.



Actually, you can use the second formula in column C, too.
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions,microsoft.public.access
external usenet poster
 
Posts: 12
Default How do I group and transpose data - macro help needed.

Thanks Glen.

Looks OK so far, but I haven't completed it yet.

Do you know of a way I can specify the paste to area rather than selecting
it?

I.E. can I somehow tell Excel to copy contents of C2 to C3:C6500, or
C2:DD6500?


"Glenn" wrote in message
...
Glenn wrote:
Chris Mitchell wrote:
I have a MS Excel table comprising 2 columns and 6500 rows. Column A
contains 366 variables, (VA001 - VA336), and Column B contains 48,
(VB01 - VB48), the AB pairings are unique but not all possible pairings
are present. This table is created monthly and is variable.

I want to be able to sort by Column A then Column B.

I then want to identify all VA001 rows and copy the corresponding Column
B entries then Transpose these to the top VA001 row and delete all VA001
rows bar the top one with the transposed Column B data so that I end up
with a single row for VA001 that is as many columns wide as is necessary
to accommodate the variable number of corresponding Column B entries.

I want to repeat this for each Column A variable so that I end up with a
table with 366 rows + header with as many columns as is necessary to
accommodate the longest row of former Colum B data however long that
might be.

I then need to apply the same to other similar tables that have
different numbers of variables for A and B.

I can do all of this manually but it is tedious.

What would a macro to do this look like?

Can I use the same macro in both MS Excel and MS Access?

TIA.

Chris


Without a macro...sort by Column A and Column B. Assuming you have
headers in Row 1, put the following in C2 and copy down as needed:

=IF(COUNTIF($A$2:$A2,$A2)=1,B2,"")

And put this in D2 and copy across and down as needed:

=IF(COUNTIF($A$2:$A2,$A2)=1,IF(INDIRECT("A"&ROW()+ COLUMN()-3)=$A2,INDIRECT("B"&ROW()+COLUMN()-3),""),"")
Select columns C:AX (or as far as you needed to go) and COPY / PASTE
SPECIAL / VALUES.

Sort by Column C and delete any rows where there is no entry in C. Then
delete Column B and sort by Column A.



Actually, you can use the second formula in column C, too.



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions,microsoft.public.access
external usenet poster
 
Posts: 1,240
Default How do I group and transpose data - macro help needed.

Chris Mitchell wrote:
Thanks Glen.

Looks OK so far, but I haven't completed it yet.

Do you know of a way I can specify the paste to area rather than selecting
it?

I.E. can I somehow tell Excel to copy contents of C2 to C3:C6500, or
C2:DD6500?




Select and Copy cell C2. Select EDIT / Go To...

In the "Reference:" box, type C2:DD6500 and click OK. Then Paste.
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
Formula or macro needed for sorting complex data issue. malycom Excel Discussion (Misc queries) 4 November 27th 08 07:24 AM
Macro needed to pull data from one worksheet and enter it in anoth bigproblem Excel Discussion (Misc queries) 2 November 18th 08 02:14 PM
macro needed to compare value and copy data underneath it to anoth Arain Excel Discussion (Misc queries) 1 April 17th 07 10:52 PM
TRANSPOSE 'group' of columns to rows tom Excel Discussion (Misc queries) 1 December 14th 06 06:19 AM
Transpose Macro Spil Excel Worksheet Functions 1 July 14th 05 09:28 AM


All times are GMT +1. The time now is 10:50 AM.

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

About Us

"It's about Microsoft Excel"