Results 1 to 6 of 6
  1. #1
    stalk is offline Competent Performer
    Windows 8 Access 2003
    Join Date
    May 2014
    Posts
    143

    How to transpose data ; make one record to 9 records and copy to excel template starting from A3

    How can I convert my table 1 to table 2 format using VBA code?



    It's like converting one line of record into 9 records. Each test will have numeric result (~Ct) and text result like positive (>0)or negative( =0)
    If all the 4 ~Ct values final rRT should be 0.


    Thank you in advance
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    You want to do this with data from an Access table? A UNION query can rearrange data then can use Export tool or VBA with TransferSpreadsheet to export query.
    Last edited by June7; 01-29-2020 at 12:36 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
    stalk is offline Competent Performer
    Windows 8 Access 2003
    Join Date
    May 2014
    Posts
    143
    its access table and I need to process at least 5 files each day and export to excel template. Number of records vary each time between 3 and 12. That means out put might have 27 to 108 records.
    can you give me an example of how the union query work?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    SELECT ID, "t1_rRT_ct" AS Test, t1 AS Result, qc FROM tablename
    UNION SELECT ID, "p1_rRT_ct", p1, qc FROM tablename
    UNION SELECT ID, "h1_rRT_ct", h1, qc FROM tablename
    UNION SELECT ID, "rp_rRT_ct", rp, qc FROM tablename
    UNION SELECT ID, "t1_rRT, IIf(t1=0,"Negative","Positive"), qc FROM tablename
    UNION SELECT ID, "p1_rRT, IIf(p1=0,"Negative","Positive"), qc FROM tablename
    UNION SELECT ID, "h1_rRT, IIf(h1=0,"Negative","Positive"), qc FROM tablename
    UNION SELECT ID, "rp_rRT, IIf(rp,"Negative","Positive"), qc FROM tablename
    UNION SELECT ID, "rRT", IIf(t1+p1+h1+rp=0,"Negative","Positive"), qc FROM tablename;

    This is essentially normalized structure data should have been in.

    There is no query builder/designer for UNION - must type or copy/paste in SQL View.


    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.

  5. #5
    stalk is offline Competent Performer
    Windows 8 Access 2003
    Join Date
    May 2014
    Posts
    143
    You ARE GENIUS. and you made my day today.
    Thank you so much for simple and effective solution. Will play with real data an update you

  6. #6
    stalk is offline Competent Performer
    Windows 8 Access 2003
    Join Date
    May 2014
    Posts
    143
    Thank yo so much again. It's working like a charm and using it at least 10 times a day.I could not stop appreciating you all the times I use it for your self less service.

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

Similar Threads

  1. Missing data in export to excel template
    By MissaLissa in forum Modules
    Replies: 1
    Last Post: 08-03-2017, 11:22 AM
  2. Replies: 5
    Last Post: 04-22-2017, 06:13 AM
  3. Query to make copy of form and record
    By banpreet in forum Queries
    Replies: 8
    Last Post: 01-05-2017, 09:36 AM
  4. DB Design starting first model , with Matrix data from Excel
    By warlock916 in forum Database Design
    Replies: 6
    Last Post: 01-11-2016, 01:47 AM
  5. Replies: 1
    Last Post: 10-28-2013, 12:32 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