Excel Macro to create school reports

1.1k views Asked by At

hi everyone i need your help, i'm a school teacher with very minor knowledge of excel macros. I've created an excel worksheet with a table includes student names and lesson scores, i need a macro to create report for every student (every row of table) to a template that i created as report template

I've been looking so hard to find any tips or help on internet but no luck so far.

I've tried searching, and found a few examples, but none quite fit..such as this one.. create macro that will convert excel rows from single sheet to new sheets ..or this one.. Excel Macro that saves data inputted from one sheet onto successive rows in another sheet Thank you so much

1

There are 1 answers

0
user2284877 On

Please try and customize as you need, this code:
(my main table header is: student_id | name | surname | group)

Sub gen_reports()

Set ref_col = Application.Selection
Set ref_col = Application.InputBox("Select ID col of main table", xTitleId, ref_col.Address, Type:=8) ' select students from student_id col

For Each C In ref_col
    Worksheets.Add.Name = C.Offset(0, 1) ' create a sheet for each student
   ActiveSheet.Select
   Range("a1").Value = "Report for " & C.Offset(0, 1) & " " & C.Offset(0, 2) & " / " & C.Offset(0, 3) ' fill each sheet with elements from each student

Next
End Sub

you can format the report(student's sheet) as you need, programatically. ex: Range("a1").Font.ColorIndex = 44 etc