winninghkjc

New Member
Joined
Jul 21, 2016
Messages
1
HI All,

Nice to meet you all. I am a study currently working as an assistant in an educational institution on a voluntary basis. I am going to consolidated the exam result of students and performing analysis.

The system we currently using is able to generate the result of each student as follow:

NameMary
Class1A
Computer
TestAssignmentExam
203040
Music
TestAssignmentExam
405060
NamePeter
Class2A
History
TestAssignmentExam
503020
Music
TestAssignmentExam
302040
Language
TestAssignmentExam
305070

<tbody>
</tbody>


I have no idea that if there is any formula I can use / vba function can let me gather the data and copy them to the summary page?

ComputerMusicHistoryLanguage
NameClassTestAssignmentExamTestAssignmentExamTestAssignmentExamTestAssignmentExam

<tbody>
</tbody>


Thank you for yours help and advice.

Many thanks,

jc.
 

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.
Welcome to the MrExcel board!

Assuming ..
- Original data in 'Sheet1' columns A:C.
- Data layout is uniform per your sample. That includes, 3 rows per subject, no blank rows within a student's 'block', a blank row between student 'blocks'.
- Maximum of 10 subjects exist. Edit 'Const' line near start of code if you want. Doesn't matter if this value is greater than the actual number, but must not be less.
- Results to go on to Sheet2.
- Sheet2 already exists and any data already on it can be removed.

.. then try this on a copy of your workbook.

Rich (BB code):
Sub Rearrange()
  Dim d As Object
  Dim a As Variant, b As Variant
  Dim i As Long, k As Long, fc As Long, dCount As Long
  
  Const MaxSubjects As Long = 10  '<- Change if required
  
  Set d = CreateObject("Scripting.Dictionary")
  d.CompareMode = 1
  With Sheets("Sheet1")
    a = .Range("A1", .Range("C" & .Rows.Count).End(xlUp).Offset(1)).Value
  End With
  ReDim b(1 To UBound(a) / 5, 1 To MaxSubjects * 3 + 2)
  b(2, 1) = "Name": b(2, 2) = "Class"
  k = 2
  For i = 1 To UBound(a)
    If a(i, 1) = "Name" Then
      k = k + 1
      b(k, 1) = a(i, 2): b(k, 2) = a(i + 1, 2)
      i = i + 2
      Do Until a(i, 2) = ""
        If d.exists(a(i, 2)) Then
          fc = d(a(i, 2)) - 1
        Else
          dCount = dCount + 1
          fc = dCount * 3
          d(a(i, 2)) = fc + 1
          b(1, fc + 1) = a(i, 2)
          b(2, fc) = "Test": b(2, fc + 1) = "Assignment": b(2, fc + 2) = "Exam"
        End If
        b(k, fc) = a(i + 2, 1): b(k, fc + 1) = a(i + 2, 2): b(k, fc + 2) = a(i + 2, 3)
        i = i + 3
      Loop
    End If
  Next i
  With Sheets("Sheet2")
    .UsedRange.ClearContents
    With .Range("A1").Resize(k, d.Count * 3 + 2)
      .Value = b
      .Columns.AutoFit
      .Offset(, 2).Resize(.Columns.Count - 2).HorizontalAlignment = xlCenter
    End With
  End With
End Sub

My data:
Excel Workbook
ABC
1NameMary
2Class1A
3Computer
4TestAssignmentExam
5203040
6Music
7TestAssignmentExam
8405060
9
10NamePeter
11Class2A
12History
13TestAssignmentExam
14503020
15Music
16TestAssignmentExam
17302040
18Language
19TestAssignmentExam
20305070
21
Sheet1



Results:
Excel Workbook
ABCDEFGHIJKLMN
1ComputerMusicHistoryLanguage
2NameClassTestAssignmentExamTestAssignmentExamTestAssignmentExamTestAssignmentExam
3Mary1A203040405060
4Peter2A302040503020305070
Sheet2
 
Upvote 0
DO YOU HAVE ACCESS TO THE RAW DATA IE CLASS, SUBJECT, NAMES AND SCORES

I feel somebody has already processed raw data to produce the table you are showing us...
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,669
Members
448,977
Latest member
moonlight6

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