Compiling data from a training report

magpie2000k

Board Regular
Joined
Sep 13, 2013
Messages
196
Hi I wonder if you can help me I have a spread sheet of training for my staff

Student
Course one
Date started
no. attempts
mark acheived
date completed
Course 2
Date started
no. attempts
mark acheived
date completed

<tbody>
</tbody>
Course three
Date started
no. attempts
mark acheived
date completed

<tbody>
</tbody>
bob smith
first aid
01/05/2018
1
65%
02/05/2018
fire safety

<tbody>
</tbody>

The columns go on and on for multiple courses
I basically need to pull a summary for the learner

However as the columns go across the page they may or may not have taken each course

so in example above bob may have taken course on but not course 2 or three but may have taken course 4 (not shown)

What I am hoping to acheive isthe following

Delegate
Course
Attempts
Pass mark
Date achieved
Bob Smith
First aid
1
65%
02/05/2018
Bob Smith
Fire
Bob Smith
Course 3
Bob Smith
Course 4
2
75%
03/05/2018

<tbody>
</tbody>

I hope that makes some rough sense. I am more looking at the general way of doing it then I should be able to adapt the formulas.

Thanks
 
Runtime error '9'
Subscript out of range

Did I do somethign wrong I am not good at macros but can follow instructions lol
 
Last edited:
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Did you change the sheet names to match your sheet names?
 
Upvote 0
as siad not good at this lol..

just teh red ones

Code:
Sub ReorganiseData()
   Dim r As Long, c As Long, i As Long, j As Long, k As Long
   Dim ary As Variant
   Dim Nary() As Variant
   
   ary = Sheets("Summary").Range("A1").CurrentRegion.Offset(1)
   j = 1
   For r = 1 To UBound(ary)
      For c = 2 To UBound(ary, 2) Step 5
         If Not ary(r, c) = "-" Then
            ReDim Preserve Nary(1 To 5, 1 To j)
            Nary(1, j) = ary(r, 1)
            For i = 2 To 5
               Nary(i, j) = ary(r, c + k)
               If k = 0 Then k = 2 Else k = k + 1
            Next i
            j = j + 1: k = 0
         End If
      Next c
   Next r
   Sheets("[COLOR=#ff0000]Sheet1[/COLOR]").Range("A1:E1").Value = Array("Student", "Course", "Attepmts", "Pass Mark", "Date Achieved")
   Sheets("[COLOR=#ff0000]Sheet1[/COLOR]").Range("A2").Resize(j - 1, 5).Value = Application.Transpose(Nary)
End Sub
 
Last edited by a moderator:
Upvote 0
What about this one
Code:
ary = Sheets("[COLOR=#ff0000]Summary[/COLOR]").Range("A1").CurrentRegion.Offset(1)
Also when posting code please use code tags, the # icon in the reply window
 
Upvote 0
sorry for being thick

Data is in a sheet names data
I want to output to sheet named result

so I change summary to "result" and the bottom two sheets to "data"

I do this and get

run-time error-13
type mismatch
 
Upvote 0
You need to change them the other way.
Code:
Sub ReorganiseData()
   Dim r As Long, c As Long, i As Long, j As Long, k As Long
   Dim ary As Variant
   Dim Nary() As Variant
   
   ary = Sheets("Data").Range("A1").CurrentRegion.Offset(1)
   j = 1
   For r = 1 To UBound(ary)
      For c = 2 To UBound(ary, 2) Step 5
         If Not ary(r, c) = "-" Then
            ReDim Preserve Nary(1 To 5, 1 To j)
            Nary(1, j) = ary(r, 1)
            For i = 2 To 5
               Nary(i, j) = ary(r, c + k)
               If k = 0 Then k = 2 Else k = k + 1
            Next i
            j = j + 1: k = 0
         End If
      Next c
   Next r
   Sheets("Result").Range("A1:E1").Value = Array("Student", "Course", "Attepmts", "Pass Mark", "Date Achieved")
   Sheets("Result").Range("A2").Resize(j - 1, 5).Value = Application.Transpose(Nary)
End Sub
 
Upvote 0
sorry idiots guide must be needed I have done this but still get error 9 subscript out of range

In project-vbaProject

VBA project (jonners export.csv)
-microsoft excel objects
-Sheet1(data)
-sheet 2 (result
This workbook

where do I put the code
 
Last edited:
Upvote 0
Which line of code is highlighted when you click Debug?
 
Upvote 0
I must sound stupid but I dont know debug gives me a drop down menu

step into run cursor etc sorry my knowledge of vba is very little
 
Upvote 0
When you run the code & it gives you the error message. There is a button on that message box called Debug. If you click-it then a row of code will be highlighted in yellow. Which one?
 
Upvote 0

Forum statistics

Threads
1,215,375
Messages
6,124,576
Members
449,174
Latest member
chandan4057

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