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
 
Math is aligned to Jones and Robinson not to Smith so how I can align Math to Smith if it is not exist there? (this is Excel not freestyle :biggrin: )
I didn't change any value
would be better if you copy table from post#9 , prepare and post here what you want to achieve
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hey sandy666,
Sorry - not trying to be difficult. I understand that is a complex operation.
The transpose is linked to the StudentCode. Hopefully, this makes it a little clearer:

From this…
StudentFirstNameStudentLastNameStudentCodeStudentYearLevelStudentFormGroupStudentHouseGroupSubjectClassCodeTeacherAssessmentAreaResult
FirstnameStudentLastNameZBB0014Year 8P3MMELBAEnglishBENG12EMr SmithUses personal strengths to prepare for complex learning tasksVery Good
FirstnameStudentLastNameZBB0014Year 8P3MMELBAEnglishBENG12EMr SmithEffectively uses digital resources (laptop, school software etc.) for learningMostly
FirstnameStudentLastNameZBB0014Year 8P3MMELBAMathsBMAT11BMr JonesUses personal strengths to prepare for complex learning tasksExcellent
FirstnameStudentLastNameZBB0014Year 8P3MMELBAPEBPE4S6AMr BlueUses personal strengths to prepare for complex learning tasksVery Good
FirstnameStudentLastNameZBB0014Year 8P3MMELBAPEBPE4S6AMr BlueOn timeConsistently
FirstnameStudentLastNameZBB0014Year 8P3MMELBATechnologyBTEC5S4BMs GreenUses personal strengths to prepare for complex learning tasksVery Good
FirstnameStudentLastNameAZB0012Year 7P2NLAKESIDEEnglish7ENGCMr YellowUses personal strengths to complete learning tasksExcellent
FirstnameStudentLastNameAZB0012Year 7P2NLAKESIDEHealth7PPECMs OrangeUses personal strengths to complete learning tasksOutstanding
FirstnameStudentLastNameAZB0012Year 7P2NLAKESIDEHumanities7GLBCMs OrangeUses personal strengths to complete learning tasksOutstanding
To this…removedtransposed to the end of each students first line
StudentFirstNameStudentLastNameStudentCodeStudentYearLevelStudentFormGroupStudentHouseGroupSubjectClassCodeTeacherAssessmentArea.1Result.1AssessmentArea.2Result.2AssessmentArea.3Result.3AssessmentArea.4Result.4AssessmentArea.5Result.5AssessmentArea.6Result.6Result.8Subject2ClassCode2Teacher2AssessmentArea.7Result.7AssessmentArea.8Result.8AssessmentArea.9Result.9AssessmentArea.10Result.10AssessmentArea.11Result.11AssessmentArea.12Result.12Subject3ClassCode3Teacher3AssessmentArea.13Result.13AssessmentArea.14Result.14AssessmentArea.15Result.15
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 TimesMostlyMaths - Get the Basics BBMAT11BMr JonesAccesses resources on learning management systemsMostlyEffectively uses digital resources (laptop, school software etc.) for learningMostlyAccepts the responsibility associated with independenceVery GoodReady for learningConsistently Uses self-reflection to build confidence and adaptabilityExcellentMaths - Get the Basics BBMAT11BMs RobinsonEquipped for ClassConsistentlyUses empathy to understand and accept othersExcellentRespects learning environmentConsistentlyCollaborates with students and teachersExcellent
 
Upvote 0
I think you should post source table and type: this is representative example of source data
because your data is changed from post to post
then post expected result from posted representative source data

how you got this from original subject?

Subject
English
English
Maths
PE
PE
Technology
English
Health
Humanities
Subject
English - Forging Ahead B
 
Last edited:
Upvote 0
Appreciate you patience sandy666. I’ll look into doing what you suggested.
 
Upvote 0
Does it matter if the cell data is all different? Wouldn't a VBA macro function based on column position?
 
Upvote 0
I don't use vba but Power Query so I don't know if it matters for vba

anyway representative source data and expected result will be appreciated
 
Upvote 0
this is an example only:

source data

StudentFirstNameStudentLastNameStudentCodeStudentYearLevelStudentFormGroupStudentHouseGroupSubjectClassCodeTeacherAssessmentAreaResult
FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithUses personal strengths to prepare for complex learning tasksVery Good
FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithUses empathy to understand and accept othersOutstanding
FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithRespects learning environmentConsistently
FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithCollaborates with students and teachersOutstanding
FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithParticipates in online meetingsMostly
FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithSeeks clarification of tasksAt Times
FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithAccesses resources on learning management systemsMostly
FirstnameStudentLastNameABB0014Year 8P3MMELBAEnglish - Forging Ahead BBENG12EMr SmithEffectively uses digital resources (laptop, school software etc.) for learningMostly
FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMr JonesUses personal strengths to prepare for complex learning tasksExcellent
FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMr JonesOn timeMostly
FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMr JonesAccepts the responsibility associated with independenceVery Good
FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMr JonesReady for learningConsistently
FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMr Jones Uses self-reflection to build confidence and adaptabilityExcellent
FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMs RobinsonEquipped for ClassConsistently
FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMs RobinsonUses empathy to understand and accept othersExcellent
FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMs RobinsonRespects learning environmentConsistently
FirstnameStudentLastNameABB0014Year 8P3MMELBAMaths - Get the Basics BBMAT11BMs RobinsonCollaborates with students and teachersExcellent


Expected result

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
ok... I need a VBA macro that will help me reorganise the data in my spreadsheet (CSV) so that:

1. After every change in subject, the subject, teacher, classcode, assessments and results are added to that student's first row of appearance.
2. The duplicate and empty cells that remain from transposing the subject data are removed and the remaining data is moved up
3. After every change in the StudentCode the loop returns to step 1.

Constant strings are StudentCode and ClassCode

The column headers are:

StudentFirstNameStudentLastNameStudentCodeStudentYearLevelStudentFormGroupStudentHouseGroupSubjectClassCodeTeacherAssessmentAreaResult


Here is an example of what I'm after:

From this…
StudentFirstNameStudentLastNameStudentCodeStudentYearLevelStudentFormGroupStudentHouseGroupSubjectClassCodeTeacherAssessmentAreaResult
FirstnameStudentLastNameABC123StudentYearLevelStudentFormGroupStudentHouseGroupsubject.1ClassCodeTeacher1AssessmentArea.1Result.1
FirstnameStudentLastNameABC123StudentYearLevelStudentFormGroupStudentHouseGroupsubject.1ClassCodeTeacher1AssessmentArea.2Result.2
FirstnameStudentLastNameABC123StudentYearLevelStudentFormGroupStudentHouseGroupsubject.1ClassCodeTeacher1AssessmentArea.3Result.3
FirstnameStudentLastNameABC123StudentYearLevelStudentFormGroupStudentHouseGroupsubject.2ClassCodeTeacher2AssessmentArea.4Result.4
FirstnameStudentLastNameABC123StudentYearLevelStudentFormGroupStudentHouseGroupsubject.2ClassCodeTeacher2AssessmentArea.5Result.5
FirstnameStudentLastNameABC123StudentYearLevelStudentFormGroupStudentHouseGroupsubject.2ClassCodeTeacher2AssessmentArea.6Result.6
FirstnameStudentLastNameABC123StudentYearLevelStudentFormGroupStudentHouseGroupsubject.3ClassCodeTeacher3AssessmentArea.7Result.7
FirstnameStudentLastNameABC123StudentYearLevelStudentFormGroupStudentHouseGroupsubject.3ClassCodeTeacher3AssessmentArea.8Result.8
FirstnameStudentLastNameABC123StudentYearLevelStudentFormGroupStudentHouseGroupsubject.3ClassCodeTeacher3AssessmentArea.9Result.9
1transposed to the end of each students first line based on ClassCode
2Remove cells
3Repeat based on StudentCode
To this…
StudentFirstNameStudentLastNameStudentCodeStudentYearLevelStudentFormGroupStudentHouseGroupSubjectClassCodeTeacherAssessmentArea.1Result.1AssessmentArea.2Result.2AssessmentArea.3Result.3AssessmentArea.4Result.4AssessmentArea.5Result.5AssessmentArea.6Result.6Subject.2ClassCode.2Teacher.2AssessmentArea.7Result.7AssessmentArea.8Result.8AssessmentArea.9Result.9AssessmentArea.10Result.10
FirstnameStudentLastNameStudentcodeStudentYearLevelStudentFormGroupStudentHouseGroupSubjectClasscodeTeacher.1AssessmentArea.1Result.1AssessmentArea.2Result.2AssessmentArea.3Result.3AssessmentArea.4Result.4AssessmentArea.5Result.5AssessmentArea.6Result.6Subject.2ClassCode.2Teacher.2AssessmentArea.7Result.7AssessmentArea.8Result.8AssessmentArea.9Result.9AssessmentArea.10Result.10


Thanks
 
Upvote 0
sure, so you will need to wait for any master of vba
have a nice day my friend :giggle:
 
Upvote 0

Forum statistics

Threads
1,215,891
Messages
6,127,603
Members
449,388
Latest member
macca_18380

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