By: Bishawajit Chakraborty

In reply to Siddharth Pande.

Thank you, SIDDHARTH, for your wonderful question.

Here is the solution to your question. Please take a look at the below steps.

Create a table with columns for Roll Number, Name, and Marks in Excel.

Enter the Roll Number, Name, and Marks for each student in the table.

Create a new sheet in Excel and name it “Marksheets”.

In cell A1 of the “Marksheets” sheet, enter the text “Roll Number”.

In cell B1, enter the text “Name”.

In cell C1, enter the text “Marks”.

Select cell A2 on the “Marksheets” sheet.

Go to the “Data” tab in the Excel ribbon and click on “Data Validation”.

In the “Data Validation” window, select “List” as the validation criteria.

In the “Source” field, enter the range of Roll Numbers from the table you created earlier.

Click “OK” to close the “Data Validation” window.

Repeat steps for cells B2 and C2, but select the range of Names and Marks respectively.

Now, select the Roll Number, Name, and Marks here.

Here is our? VBA code. Therefore, you can apply this code to solve your problem.

Sub Generate_Marksheet()
Dim roll_number As String
Dim name As String
Dim marks As Integer
Dim i As Integer
i = 2 'Starting at row 2 of the Marksheets sheet
Do While Worksheets("Marksheets").Cells(i, 1) <> "" 'Loop until the Roll Number column is empty
roll_number = Worksheets("Marksheets").Cells(i, 1).Value
name = Worksheets("Marksheets").Cells(i, 2).Value
marks = Worksheets("Marksheets").Cells(i, 3).Value
'Creating a new sheet for each Roll Number
Worksheets.Add(After:=Worksheets(Worksheets.Count)).name = roll_number
'Adding the Name and Marks to the sheet
Worksheets(roll_number).Range("A1").Value = "Name"
Worksheets(roll_number).Range("B1").Value = "Marks"
Worksheets(roll_number).Range("A2").Value = name
Worksheets(roll_number).Range("B2").Value = marks
i = i + 1 'Moving to the next row
Loop
End Sub

Here, you will see the final result in another sheet with names and marks.

I hope this may solve your issue.?

Bishawajit, on behalf of ExcelDemy