Extracting Exam data from Broadsheet

dpbarry

Board Regular
Joined
Feb 10, 2003
Messages
214
Office Version
  1. 2016
Platform
  1. Windows
Hi Folks

I have an exam spreadsheet which has everything in columns - Surname, forename, exam number and then a list of subjects (26 in total) in the form of:

ForenameSurnameRegExamArtBiologyBusiness StChemistryComputingDramaEnglishFrenchFurther MathsGeography
JaneDoe14A5055
B​
BB
SarahPayne14D5058AAA
OrlaBriggs14C5059BAA

The are 101 Rows (number of students) and each student could have received a grade for 1 to 6 subjects

What a teacher would like - if possible - is for the data to be stripped down and only showing grades a student received but to be presented in the form of

ForenameSurnameSubjectGrade
JaneDoeChemistryB
JaneDoeFrenchB
JaneDoeGeographyB
SarahPayneArtA
SarahPayneBusiness StA
SarahPayneComputingA
OrlaBriggsBiologyB
OrlaBriggsComputingA
OrlaBriggsFrenchA

I'm currently using Microsoft Excel 2016 and any help would be greatly appreciated.

Regards

Declan
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I'm currently using Microsoft Excel 2016
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

How about
VBA Code:
Sub dpbarry()
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, nr As Long
   
   Ary = Sheets("Sheet1").Range("A1").CurrentRegion.Value2
   ReDim Nary(1 To UBound(Ary) * 26, 1 To 4)
   
   For r = 2 To UBound(Ary)
      For c = 5 To UBound(Ary, 2)
         If Ary(r, c) <> "" Then
            nr = nr + 1
            Nary(nr, 1) = Ary(r, 1)
            Nary(nr, 2) = Ary(r, 2)
            Nary(nr, 3) = Ary(1, c)
            Nary(nr, 4) = Ary(r, c)
         End If
      Next c
   Next r
   Sheets("Sheet2").Range("A2").Resize(nr, 4).Value = Nary
End Sub
Change sheet names to suit.
 
Upvote 0
Solution
Fluff.

You are an Absolute Star. :)

The teacher will be chuffed to bits and it will probably earn me brownie points but I'll be letting the teacher know that it was all your work.

Greatly appreciated

Regards

Declan
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
You're welcome & thanks for the feedback.

Its great that you solved my query so quickly but I'm also intrigued as to what the code is actually doing. Could you elaborate on the code??

Regards

Declan
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

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