Results 1 to 3 of 3
  1. #1
    DHKMDABB is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    2

    Selected columns to rows

    I need your help, I have extraction report from calculation program and don’t have access to tables. When I import it to MS Access it looks like attached Sheet1. Is there a simple SQL query or VBA code which will allow me to import the data to new Sheet2 table? Fields 1,7&13 will always be the same and I want them to be column names, Fields 4, 10 &14 contains data which will be different each time I delete the old calculation from Sheet1 and import a new one. I would like to be done in Access as I have to import few hundred calculations and store it in Sheet2 table.
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Field2, Field3, Field5, Field6, Field8, Field9, Field11, Field12, Field16 can be discarded?

    Field14 does not have data, Field15 has data.

    If I understand correctly, result from this example will be 51 fields and one record.

    You need to pivot 3 sets of data. This is a CROSSTAB query. CROSSTAB requires 3 fields. I think will need another field with a common value on each row. Each import will need this field populated, number 1 will serve. Can use the ID field for this. An UPDATE query can populate the field. This will be RowHeading field.

    For one method of CROSSTAB for multiple sets of values review http://allenbrowne.com/ser-67.html#MultipleValues

    Another approach is to do 3 separate CROSSTAB queries then join them on the ID field.

    Here is one of the CROSSTAB queries:
    TRANSFORM First(Sheet1.Field4) AS FirstOfField4
    SELECT Sheet1.ID
    FROM Sheet1
    GROUP BY Sheet1.ID
    PIVOT Sheet1.Field1;

    Use the query that joins the 3 crosstabs as source for inserting record into the final table.
    Last edited by June7; 04-18-2014 at 10:35 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    DHKMDABB is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    2
    June7 Thanks for your help crosstab qry. does the job.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 02-25-2014, 01:09 AM
  2. Replies: 12
    Last Post: 07-31-2013, 01:29 PM
  3. Copying selected rows from an access table.
    By Monu in forum Import/Export Data
    Replies: 1
    Last Post: 04-10-2013, 12:15 PM
  4. VBA to import selected columns to Access
    By jhrBanker in forum Programming
    Replies: 3
    Last Post: 02-16-2012, 05:29 PM
  5. Rows to columns
    By Jim.H. in forum Access
    Replies: 1
    Last Post: 01-28-2012, 05:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums