MS Access Query -Transpose Data

bbcdancer

New Member
Joined
Sep 28, 2010
Messages
8
Can this be done by SQL query in MS Access or do I need VBA to do this?

From Table 1 to Table 2, the 'Name' column will contain over 20k names and the 'Product' column is fixed at 18 products.

(I used the | pipe as a seperator in the below tables, but this is only to illustrate how the table would look like.)

Table 1: Before

Name | Product
----------------------
Rob | AAA
Rob | BBB
Jane | BBB
Rob | CCC
Fred | EEE
Jack | AAA
Rob | DDD
MIKE | CCC
MIKE | DDD
......


Table 2: After

Name | AAA | BBB | CCC | DDD | EEE | ...TTT
-----------------------------------------------
Rob | AAA | BBB | CCC | DDD |
Jane | | BBB | | |
Fred | | | | | EEE
Jack | AAA | | | |
Mike | | | CCC | DDD |
.......

Any help is appreciated.
 
Last edited:

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try looking at a CrossTab query to see if that will do what you want.
 
Upvote 0
Following up Trevor's suggestion

Build a query with 3 fields (Name once, Product twice).
Change it to a Crosstab (Query > Crosstab, or for 2007/2010, Design tab > Crosstab).
In the Orientation row, make the fields Row heading, Column heading, Value.
In the Totals row, leave the first two fields as Group By, and make the third Max.

Denis
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,152
Members
452,891
Latest member
JUSTOUTOFMYREACH

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