Hi,
I am working on a Grading Form that generates automatically Exam sheets based on a list of students by clicking on a “Start” button. If 10 students are registered, then 10 Exam sheets are generated when clicking on “Start”. If 15 students, then 15 Exam sheets are generated…
The tricky part that I encounter is that based on the student “age” entered, the Exam Sheet generated should be different: 2 possible sheets can be generated: “Exam Sheet Child” or “Exam Sheet Adult” (Both sheets already exist in the workbook and would need to be duplicated based on the student “age”).
My problem is that the Exam Sheet are created but do not correspond to the correct “age” criteria. It only does for the first student in the list while other only take the “Exam Sheet Adult”. I’m sure that the problem can be easily solved, but I’m stuck and do not have enough experience in VBA.
You will find below the corresponding line of code (part of a bigger one) that I wrote and presents a problem:
With ThisWorkbook
'Repeat action to add sheet based on number of filled cells in student column
For i = 10 To LastCell
If Cells(i, 10).Value = "Children" Then
'Code to add children sheet with name of student
Worksheets("Exam Sheet Child").Visible = xlSheetVisible
Newname = ThisWorkbook.Worksheets("Grading exam - Participants").Cells(i, 6).Value 'find the student name to add to sheet title
Worksheets("Exam Sheet Child ").Copy after:=.Sheets(Sheets.Count) 'Code to copy template from sheet " Exam Sheet Child " at the end of the workbook
ActiveSheet.Name = Newname
Worksheets("Exam Sheet Child ").Visible = xlSheetVeryHidden
Else
'Code to add adult sheet with name of student
Worksheets("Exam Sheet Adult").Visible = xlSheetVisible
Newname = ThisWorkbook.Worksheets("Grading exam - Participants").Cells(i, 6).Value 'find the student name to add to sheet title
Worksheets("Exam Sheet Adult").Copy after:=.Sheets(Sheets.Count) 'Code to copy template from sheet " Exam Sheet Adult" at the end of the workbook
ActiveSheet.Name = Newname
Worksheets("Exam Sheet Adult").Visible = xlSheetVeryHidden
End If
Next
End With
Thank you for your help,
N.
Bookmarks