+ Reply to Thread
Results 1 to 14 of 14

From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

Hybrid View

Rick Vu From 1 row in Excel, I need... 09-23-2022, 10:12 PM
MarvinP Re: From 1 row in Excel, I... 09-23-2022, 10:40 PM
Rick Vu Re: From 1 row in Excel, I... 09-24-2022, 08:17 AM
Rick Vu Re: From 1 row in Excel, I... 09-24-2022, 08:18 AM
sandy666 Re: From 1 row in Excel, I... 09-23-2022, 11:07 PM
Rick Vu Re: From 1 row in Excel, I... 09-24-2022, 08:27 AM
Glenn Kennedy Re: From 1 row in Excel, I... 09-24-2022, 03:29 AM
Rick Vu Re: From 1 row in Excel, I... 09-24-2022, 08:28 AM
Czeslaw Re: From 1 row in Excel, I... 09-24-2022, 06:36 AM
JohnTopley Re: From 1 row in Excel, I... 09-24-2022, 07:01 AM
Rick Vu Re: From 1 row in Excel, I... 09-24-2022, 08:29 AM
Rick Vu Re: From 1 row in Excel, I... 09-24-2022, 08:29 AM
HansDouwe Re: From 1 row in Excel, I... 09-24-2022, 08:47 AM
Glenn Kennedy Re: From 1 row in Excel, I... 09-24-2022, 08:29 AM
  1. #1
    Registered User
    Join Date
    11-24-2021
    Location
    East Palestine, Ohio
    MS-Off Ver
    office 365
    Posts
    13

    From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    Hi,

    Can someone tell me how to do the following. I have a spreadsheet that has over 1000 rows. I want to convert each row into as many rows as how many students posted a score in each of the rows. (up to 10 scores per row) Please see my attachment for a good example of what I am looking to do. My example only shows 2 rows but my actual table contains over 1000 rows.

    Thank you for any help
    Attached Files Attached Files
    Last edited by Rick Vu; 09-23-2022 at 10:16 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,333

    Re: From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    Hi Rick,

    Because you have the latest version of Excel you have Power Query. In Power Query there is an "UnPivot" function that makes your problem a snap.

    Here are the steps:
    Select cell A1 on your worksheet.
    Select the Data Tab and click on "Get Data dropdown
    Select "From Other Sources" and then "From Table/Range"
    The Power Query window will appear....
    Select the first 4 columns using Ctrl Click
    Right click on any of the selected columns and then "UnPivot Other Columns"
    Click on the Home tab in the PQ editor and Close and Load.

    Problem done!!!

    You could delete the "Attribute" column either before or after the above to make it look exactly like you show in your example.

    Hope this helps.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    11-24-2021
    Location
    East Palestine, Ohio
    MS-Off Ver
    office 365
    Posts
    13

    Re: From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    Much appreciated Marvin, IT WORKS, Thank you very much

  4. #4
    Registered User
    Join Date
    11-24-2021
    Location
    East Palestine, Ohio
    MS-Off Ver
    office 365
    Posts
    13

    Re: From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    Thank you Marvin, IT WORKS, much appreciated

  5. #5
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    Power Query

    another way

    Result
    School Subject Tested By Date Score
    Center Twp. Math John Doe
    20220620
    5
    Center Twp. Math John Doe
    20220620
    4
    Center Twp. Math John Doe
    20220620
    3
    Center Twp. Math John Doe
    20220620
    1
    Center Twp. Math John Doe
    20220620
    1
    Center Twp. Math John Doe
    20220620
    4
    Hopewell Science Mary Jane
    20220701
    5
    Hopewell Science Mary Jane
    20220701
    5
    Hopewell Science Mary Jane
    20220701
    2
    Hopewell Science Mary Jane
    20220701
    4
    Hopewell Science Mary Jane
    20220701
    3
    Hopewell Science Mary Jane
    20220701
    4
    Hopewell Science Mary Jane
    20220701
    1
    Hopewell Science Mary Jane
    20220701
    2


    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        Merge = Table.CombineColumns(Table.TransformColumnTypes(Source, {{"Student 1", type text}, {"Student 2", type text}, {"Student 3", type text}, {"Student 4", type text}, {"Student 5", type text}, {"Student 6", type text}, {"Student 7", type text}, {"Student 8", type text}, {"Student 9", type text}, {"Student 10", type text}}, "en-GB"),{"Student 1", "Student 2", "Student 3", "Student 4", "Student 5", "Student 6", "Student 7", "Student 8", "Student 9", "Student 10"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Score"),
        Rep = Table.ReplaceValue(Merge," ","",Replacer.ReplaceText,{"Score"}),
        Split = Table.ExpandListColumn(Table.TransformColumns(Rep, {{"Score", Splitter.SplitTextByRepeatedLengths(1), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Score"),
        Type = Table.TransformColumnTypes(Split,{{"Score", Int64.Type}})
    in
        Type

  6. #6
    Registered User
    Join Date
    11-24-2021
    Location
    East Palestine, Ohio
    MS-Off Ver
    office 365
    Posts
    13

    Re: From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    Thank you Sandy,

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    Or a formula (made messier because some blank cells contain spaces and others do not):

    =IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($A$2:$A$3)/(TRIM($E$2:$N$3)<>""),ROWS(A$12:A12)),1),"")
    copied across & down... and

    =IFERROR(INDEX(INDEX($2:$3,MATCH(A12,$A$2:$A$3,0),),AGGREGATE(15,6,COLUMN($E$2:$N$2)/(TRIM(INDEX($E$2:$N$3,MATCH(A12,$A$2:$A$3,0),))<>""),COUNTIF(A$12:A12,A12))),"")
    copied down.

    see file.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  8. #8
    Registered User
    Join Date
    11-24-2021
    Location
    East Palestine, Ohio
    MS-Off Ver
    office 365
    Posts
    13

    Re: From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    Thanks Glen

  9. #9
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,417

    Re: From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    Power Query
    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"School", type text}, {"Subject", type text}, {"Tested By", type text}, {"Date", Int64.Type}, {"Student 1", Int64.Type}, {"Student 2", Int64.Type}, {"Student 3", Int64.Type}, {"Student 4", Int64.Type}, {"Student 5", Int64.Type}, {"Student 6", Int64.Type}, {"Student 7", Int64.Type}, {"Student 8", Int64.Type}, {"Student 9", Int64.Type}, {"Student 10", Int64.Type}}),
        #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"School", "Subject", "Tested By", "Date"}, "Attribute", "Value"),
        #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute"}),
        #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Value", "Student Score"}})
    in
        #"Renamed Columns"
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,831

    Re: From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    Yet another ... VBA
    Sub X_10()
    Dim ar, arr
    ar = Sheets("Sheet1").[a1].CurrentRegion
    ReDim arr(1 To 5, 1 To 1)
    Application.ScreenUpdating = False
    n = 0
    For r = 2 To UBound(ar, 1)
        For c = 5 To 14
            If IsNumeric(ar(r, c)) Then
                n = n + 1
                ReDim Preserve arr(1 To 5, 1 To n)
                arr(5, n) = ar(r, c)
                For cc = 1 To 4
                    arr(cc, n) = ar(r, cc)
                Next cc
            End If
        Next c
    Next r
    
    With Sheets("Sheet2")
    .[A2].Resize(n, 5) = Application.Transpose(arr)
    End With
    
    Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  11. #11
    Registered User
    Join Date
    11-24-2021
    Location
    East Palestine, Ohio
    MS-Off Ver
    office 365
    Posts
    13

    Re: From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    Thanks John

  12. #12
    Registered User
    Join Date
    11-24-2021
    Location
    East Palestine, Ohio
    MS-Off Ver
    office 365
    Posts
    13

    Re: From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    Thanks Czeslaw

  13. #13
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    I've an other solution with formula:

    Please try for the student score
    Formula: copy to clipboard
    =FILTERXML("<z><m>"&TEXTJOIN("</m><m>",,TRIM(E2:N3))&"</m></z>","//m")
    Please create for the other information an helper column =COUNT(E$2:N2) and try formula
    Formula: copy to clipboard
    =IFERROR(INDEX(A$2:D$3,IFNA(MATCH(ROW(A1)-1,O$2:O$3,1)+1,1),0),"")
    Attached Files Attached Files

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: From 1 row in Excel, I need to create up to 10 rows depending on a Students Score

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please click on "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

+ 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. Replies: 2
    Last Post: 09-21-2022, 02:25 PM
  2. Rank Students by Score
    By mwatkins2021 in forum Excel General
    Replies: 1
    Last Post: 03-17-2021, 05:55 PM
  3. schedule students in groups to attend classes depending on interest
    By accelatexcel in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-26-2018, 09:13 PM
  4. Script to create averages of subgroups of rows, depending on content of rows
    By LennaKB in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2016, 10:10 AM
  5. Analysing Students Exams Score
    By oluagbe1 in forum Excel General
    Replies: 10
    Last Post: 04-22-2014, 09:47 AM
  6. Pass or Fail Remark in students score
    By oluagbe1 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-20-2014, 03:09 PM
  7. [SOLVED] Count number of students depanding on their score.
    By moxeve in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-17-2013, 06:01 AM

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