Andrew1995

New Member
Joined
Jan 16, 2020
Messages
3
Office Version
2016
Platform
Windows
Dear friends
i am in need of some help. i am quite new and learning. i have done some work on it but dont know how to continue now. So basically i have a ''master'' called sheet that has a list of students from A6 TO A36 and their student ids from B6 to B36 and from C6 to C36 to have their unique password. the columns D E and going on have there subjects and grades. so what i want to do is as follows:
1) After i add the details of the students and their grades, all their details to be copied to a new sheet for each student in a new workbook automatically as in the example below. (one workbook with new sheet for every student) i will attach the master sheet and a new student sheet for example purposes.
2)After the new workbook is created i want when i open it to have all the details hidden and a search box to appear directly. each student must add their unique id and there unique password to show their sheet only and to not have any other options to do.


master sheet.png
STUDENT SHEET.png
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
771
This code should create the sheets with the names as the tabs.

Then need to adapt it to loop through and create what is to be completed to each sheet?

VBA Code:
Sub Students ()

    Dim xRg As Excel.Range
    Dim wSh As Excel.Worksheet
    Dim wBk As Excel.Workbook
    Set wSh = ActiveSheet
    Set wBk = ActiveWorkbook
    Application.ScreenUpdating = False
    Dim Lastrow as Long

Lastrow = Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Row

    For Each xRg In wSh.Range("A6:A" & Lastrow)
        With wBk
            .Sheets.Add after:=.Sheets(.Sheets.Count)
            On Error Resume Next
            ActiveSheet.Name = xRg.Value
            If Err.Number = 1004 Then
              Debug.Print xRg.Value & " already used as a sheet name"
            End If
            On Error GoTo 0
        End With
    Next xRg
    Application.ScreenUpdating = True
End Sub
 

Andrew1995

New Member
Joined
Jan 16, 2020
Messages
3
Office Version
2016
Platform
Windows
just tested it. it works but it creates the new sheets in the same workbook. i need the new sheets to be created in a new workbook. thanks any ideas
 

adaltenburger

New Member
Joined
May 20, 2020
Messages
2
Office Version
365, 2019
Platform
Windows, MacOS
Hi Andrew,
Have you found the solution for your school project? I'm a fresher at the New Mexico State University and need help cause I'm a complete noob... I've also contacted Jon Acampora from ExcelCampus, but still waiting for the reply.
 

adaltenburger

New Member
Joined
May 20, 2020
Messages
2
Office Version
365, 2019
Platform
Windows, MacOS
Hi Andrew,
Have you found the solution for your school project? I'm a fresher at the New Mexico State University and need help cause I'm a complete noob...

>>>>

Quoted line is collapsed

>>>>

Update: is it also possible to export the sheets to the Tableau Workspace? Thanks.
 

Mentor82

Active Member
Joined
Dec 30, 2018
Messages
307
just tested it. it works but it creates the new sheets in the same workbook. i need the new sheets to be created in a new workbook. thanks any ideas
Hi,
I just amended your code. Check it out now. All the worksheets should be now created in newly created workbook.

Code:
 

Mentor82

Active Member
Joined
Dec 30, 2018
Messages
307
Hi,
I just amended your code again. I did it previously on mobile and attached it to the post, however it did not save. Checki it out now.

VBA Code:
Sub Students ()

    Dim xRg As Excel.Range
    Dim wSh As Excel.Worksheet
    Dim wBk As Excel.Workbook
    Dim nWb as Workbook
   
    Set wBk = ActiveWorkbook
    Set wSh = wBk.ActiveSheet
  

    Application.ScreenUpdating = False
    Dim Lastrow as Long

Lastrow = Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Row
    
    Set nWb = Workbooks.Add
   
    For Each xRg In wSh.Range("A6:A" & Lastrow)
        With nWb
            .Sheets.Add after:=.Sheets(.Sheets.Count)
            On Error Resume Next
            ActiveSheet.Name = xRg.Value
            If Err.Number = 1004 Then
              Debug.Print xRg.Value & " already used as a sheet name"
            End If
            On Error GoTo 0
        End With
    Next xRg
    Application.ScreenUpdating = True
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,099,006
Messages
5,465,962
Members
406,457
Latest member
Pinky Rose Jordan

This Week's Hot Topics

Top