+ Reply to Thread
Results 1 to 12 of 12

Questionnaire with question loop. Output in rows instead of columns

  1. #1
    Registered User
    Join Date
    08-08-2017
    Location
    Skanderborg, Denmark
    MS-Off Ver
    365
    Posts
    7

    Questionnaire with question loop. Output in rows instead of columns

    Hi,

    I have created a questionnaire in HarvestYourdata. The data output i get, is as listed in the first 5 rows in the attached excel file.

    The questionnaire includes a loop of 3 questions, that continous in a new column each time.

    I would like the answers for each question to appear under each other, instead of next to eachother. I have manually created the output I would like, below the first 5 rows in Excel. Is there anyway to do this quickly?
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Questionnaire with question loop. Output in rows instead of columns

    As I am interested in Power Query, which i am learning, I've been playing with this all day. See the Pivot tab in the attached file. The PQ code I used is below:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    08-08-2017
    Location
    Skanderborg, Denmark
    MS-Off Ver
    365
    Posts
    7

    Re: Questionnaire with question loop. Output in rows instead of columns

    Thank you AliGW, this worked wonders.

    I have not worked with PQ before, but this seems to work. Am I right in assuming I can use this in a macro as well? Or can I create a PQ Masterfile?

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Questionnaire with question loop. Output in rows instead of columns

    As I said, I am only just beginning to learn myself how it works, so at the moment, I can't answer your added questions - sorry. What I would do is load my table into PQ, then copy the code into the code editor window and see if it works on the larger, real data set. If not, come back and we might be able to tweak it.

    It is possible that someone with VBA skills could write you a macro that would do the same thing.

  5. #5
    Registered User
    Join Date
    08-08-2017
    Location
    Skanderborg, Denmark
    MS-Off Ver
    365
    Posts
    7

    Re: Questionnaire with question loop. Output in rows instead of columns

    I just tried it with the real data set (63 columns). And it does not seem to work for me. Is there a way to include more columns in the PQ code?

    Also, the dataset will probably vary from week to week. I cannot figure out if the code changes all data marked, or only a set number oc columns and rows?.

    Again, thank you for your assistance.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Questionnaire with question loop. Output in rows instead of columns

    I think, given your comment about the dataset changing, you are going to struggle with this, even with VBA, because any solution offered is going to rely on there being patterns in the data and fixed logic.

    Shall I move this to the VBA section and see if anyone can help you there?

  7. #7
    Registered User
    Join Date
    08-08-2017
    Location
    Skanderborg, Denmark
    MS-Off Ver
    365
    Posts
    7

    Re: Questionnaire with question loop. Output in rows instead of columns

    I am not sure if I explained myself proberly.

    The data will always have the same layout, but the size will differ. It's basically the same 3 questions in a loop. Sometimes it will loop 20 times, other times it will loop more or less. It will always be 1 row of headlines, and 4 rows of data.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Questionnaire with question loop. Output in rows instead of columns

    OK, well I'll move you to the VBA section and see if someone can help.

  9. #9
    Registered User
    Join Date
    08-08-2017
    Location
    Skanderborg, Denmark
    MS-Off Ver
    365
    Posts
    7

    Re: Questionnaire with question loop. Output in rows instead of columns

    Thank you

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Questionnaire with question loop. Output in rows instead of columns

    I've put out a call for help - hopefully someone will pop along soon.

  11. #11
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Questionnaire with question loop. Output in rows instead of columns

    Please Login or Register  to view this content.
    here's my hack and slash solution

    created a worksheet to output your data
    you can move it anywhere after the macro has run...or add this into code later should you want

    so select original sheet (its a copy of your sheet minus your manual data entry at the bottom) and then run the code

    i've commented as much of the code as possible so its hopefully easy to understand what i did where
    Attached Files Attached Files
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  12. #12
    Registered User
    Join Date
    08-08-2017
    Location
    Skanderborg, Denmark
    MS-Off Ver
    365
    Posts
    7

    Re: Questionnaire with question loop. Output in rows instead of columns

    Thank you for your help,

    I ended up making it work on my own, with this piece of VBA

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Handling output from REDCAP online questionnaire
    By H28Sailor in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-18-2016, 10:06 PM
  2. Replies: 1
    Last Post: 02-02-2015, 11:31 AM
  3. Loop through rows with VBA and select an excel output file with selectable dates
    By craigsmack in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-09-2014, 05:52 PM
  4. Loop Across Columns...If Blank Cell, Loop Down Rows
    By flindy87 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2014, 07:05 PM
  5. Loop Across Columns If Blank Cell Loop Down Rows
    By flindy87 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2014, 10:22 AM
  6. Replies: 2
    Last Post: 01-28-2014, 11:44 PM
  7. loop through rows and output calculated values on new sheet
    By leejc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-03-2011, 07:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1