Transpose multiple rows to a single row based on change of cell and then remove repeated data

AndrewNic

New Member
Joined
Aug 2, 2020
Messages
11
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello,
I'm in need of some assistance with re-organising our data. We need to transpose and remove duplicates from an excel CSV so it can be accepted by other program or introduced to a PDF form.

We get this:

StudentCodeFirstLastYearFormHouseSubjectCodeTeacherAssessmentResult
ABC123JohnSmithYear 8P3MMELBEnglishBENGJane SMITHOn TimeYes
ABC123JohnSmithYear 8P3MMELBEnglishBENGJane SMITHEquippedYes
CBA321ThomasJonesYear 7PN2NEWTMathsBMATTim APPLEOn TimeYes
CBA321ThomasJonesYear 7PN2NEWTEnglishBENGJane SMITHReady to learnSometimes

We need:
StudentCodeFirstLastYearFormHouseSubjectCodeTeacherAssessmentResultAssessmentResultSubjectTeacherAssessmentResult
ABC123JohnSmithYear 8P3MMELBEnglishENGBJane SMITHOn TimeYesEquippedYesMathsTim AppleOn TimeYes
CBAThomasJonesYear 7PN2NEWTMathsBMATTim APPLEOn TimeYesEquippedYesEnglishJane SMITHReady to LearnSometimes

Put simply, we need a macro that adds the subject, teacher, assessment, and result to the end of each change of student code and removes the repeated student code, first, last, year, form and house.

Really appreciate anyone's help. I tried editing various macro but cant get anything to work.

Cheers,

Andrew
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
your expected result is illogical or I misunderstood your explanation

part of the result

StudentCodeFirstLastYearFormHouseSubjectCodeTeacherAssessmentResult
ABC123JohnSmithYear 8P3MMELBEnglishBENGJane SMITHOn TimeYes
CBA321ThomasJonesYear 7PN2NEWTMathsBMATTim APPLEOn TimeYes
 
Upvote 0
Hi Sandy666,

Sorry if my explanation wasn't very clear. Let me see if I can illustrate it a little better. We have this...

SemesterReportAllResultsCsvExport Generated - 2020-07-31_0715PM.xlsm
ABCDEFGHIJK
1StudentFirstNameStudentLastNameStudentCodeStudentYearLevelStudentFormGroupStudentHouseGroupSubjectClassCodeTeacherAssessmentAreaResult
2FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithUses personal strengths to prepare for complex learning tasksVery Good
3FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithUses empathy to understand and accept othersOutstanding
4FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithRespects learning environmentConsistently
5FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithCollaborates with students and teachersOutstanding
6FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithParticipates in online meetingsMostly
7FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithSeeks clarification of tasksAt Times
8FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithAccesses resources on learning management systemsMostly
9FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithEffectively uses digital resources (laptop, school software etc.) for learningMostly
10FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMr JonesUses personal strengths to prepare for complex learning tasksExcellent
11FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMr JonesOn timeMostly
12FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMr JonesAccepts the responsibility associated with independenceVery Good
13FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMr JonesReady for learningConsistently
14FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMr Jones Uses self-reflection to build confidence and adaptabilityExcellent
15FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMs RobinsonEquipped for ClassConsistently
16FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMs RobinsonUses empathy to understand and accept othersExcellent
17FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMs RobinsonRespects learning environmentConsistently
18FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMs RobinsonCollaborates with students and teachersExcellent
SemesterReportAllResultsCsvExpo


We need to transpose the data so we have the Subject, Class, Teacher, AssessmentArea, and Result added to the end of the first line of the StudentFirstName, Lastname, StudentCode, Formgroup, StudentHouseGroup. For every change in StudentCode (a unique code) we also need to remove the empty rows left by the previous transpose and repeat the process.

SemesterReportAllResultsCsvExport Generated - 2020-07-31_0715PM.xlsm
ABCDEFGHIJKLMNOPQRSTU
1StudentFirstNameStudentLastNameStudentCodeStudentYearLevelStudentFormGroupStudentHouseGroupSubjectClassCodeTeacherAssessmentArea1Result1AssessmentArea2Result2AssessmentArea3Result3AssessmentArea4Result4AssessmentArea5Result5AssessmentArea6Result6
2FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithUses personal strengths to prepare for complex learning tasksVery GoodUses empathy to understand and accept othersOutstandingRespects learning environmentConsistentlyCollaborates with students and teachersOutstandingParticipates in online meetingsMostlySeeks clarification of tasksAt Times
3FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr Smith
4FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr Smith
5FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr Smith
6FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr Smith
7FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr Smith
SemesterReportAllResultsCsvExpo



In the end, we should have:

Student1Name Student1LastName Student1Code Student1YearLevel Student1Form Student1House Subject1 ClassCode Teacher Assessment1 Result1 Assessment2 Result2 Assessment3 Result3 ..... Assessment6 Result6 Subject2 Classcode2 Teacher2 Assessment7 Result7....

Student2Name Student2LastName Student2Code Student1YearLevel Student2Form Student2House Subject1 ClassCode Teacher Assessment1 Result1 Assessment2 Result2 Assessment3 Result3 ..... Assessment6 Result6 Subject2 Classcode2 Teacher2 Assessment7 Result7....


I was thinking that we should be able to count the results for a subject, transpose the subject results, remove the rows, repeat until end, then if change in StudentCode, count subject assessments, tranposes, remove rows... so forth and so on. I understand the logic of what I want to do, I just dont have the VB coding skills to write the code.

I hope this helps. Thanks in advance - I really appreciate anything that we enable me to do this.

Andrew
 
Upvote 0
maybe

StudentFirstNameStudentLastNameStudentCodeStudentYearLevelStudentFormGroupStudentHouseGroupSubjectClassCodeTeacherAssessmentArea.1Result.1AssessmentArea.2Result.2AssessmentArea.3Result.3AssessmentArea.4Result.4AssessmentArea.5Result.5AssessmentArea.6Result.6AssessmentArea.7Result.7AssessmentArea.8Result.8AssessmentArea.9
FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithUses personal strengths to prepare for complex learning tasksVery GoodUses empathy to understand and accept othersOutstandingRespects learning environmentConsistentlyCollaborates with students and teachersOutstandingParticipates in online meetingsMostlySeeks clarification of tasksAt TimesAccesses resources on learning management systemsMostlyEffectively uses digital resources (laptopMostly school software etc.) for learning
FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMr JonesUses personal strengths to prepare for complex learning tasksExcellentOn timeMostlyAccepts the responsibility associated with independenceVery GoodReady for learningConsistently Uses self-reflection to build confidence and adaptabilityExcellent
FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMs RobinsonEquipped for ClassConsistentlyUses empathy to understand and accept othersExcellentRespects learning environmentConsistentlyCollaborates with students and teachersExcellent
 
Last edited:
Upvote 0
Hey Sandy666,

That would work. As long as the column headers for AssessmentArea and AssessmentResult related as there is likely to be upto 36 assessments and results for each student.

Is that possible?
 
Upvote 0
as you can see Assessment9 doesn't have Result9 (should have?)

note: refresh thread, I changed table

btw. my solution doesn't work on Mac
 
Last edited:
Upvote 0
It should - in the excel sheet, each student can have up to 6 subjects with 6 assessment areas and 6 assessment results.

Changes make perfect sense.
 
Upvote 0
see if this is ok for you

StudentFirstNameStudentLastNameStudentCodeStudentYearLevelStudentFormGroupStudentHouseGroupSubjectClassCodeTeacherAssessmentArea.1Result.1AssessmentArea.2Result.2AssessmentArea.3Result.3AssessmentArea.4Result.4AssessmentArea.5Result.5AssessmentArea.6Result.6AssessmentArea.7Result.7AssessmentArea.8Result.8
FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithUses personal strengths to prepare for complex learning tasksVery GoodUses empathy to understand and accept othersOutstandingRespects learning environmentConsistentlyCollaborates with students and teachersOutstandingParticipates in online meetingsMostlySeeks clarification of tasksAt TimesAccesses resources on learning management systemsMostlyEffectively uses digital resources (laptop, school software etc.) for learningMostly
FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMr JonesUses personal strengths to prepare for complex learning tasksExcellentOn timeMostlyAccepts the responsibility associated with independenceVery GoodReady for learningConsistently Uses self-reflection to build confidence and adaptabilityExcellent
FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMs RobinsonEquipped for ClassConsistentlyUses empathy to understand and accept othersExcellentRespects learning environmentConsistentlyCollaborates with students and teachersExcellent
 
Upvote 0
ah... after the 6th result for English it needs to add the results for maths to the same row:

StudentName StudentLastName ... Subject ClassCode Teacher AssessArea.1 Result.1 ... AssessArea.6 Result.6 Subject2 ClassCode2 Teache2 AssessArea.7 Result.7 AssessArea.8 Result.8 ...

Detect change in StudentCode

Student2Name Student2LastName ... and so on

I hope that makes sense?
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,595
Members
449,089
Latest member
Motoracer88

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