How to create a new sheet based on student Id numbers
Closed
bookman35
Posts
1
Registration date
Monday 19 April 2021
Status
Member
Last seen
19 April 2021
-
19 Apr 2021 à 13:15
vcoolio Posts 1411 Registration date Thursday 24 July 2014 Status Contributor Last seen 6 September 2024 - 23 Apr 2021 à 09:28
vcoolio Posts 1411 Registration date Thursday 24 July 2014 Status Contributor Last seen 6 September 2024 - 23 Apr 2021 à 09:28
Related:
- Sheet id student
- Example of student number - Best answers
- Example of id number in student id - Best answers
- Office home & student 2019 - Download - Office suites
- Little alchemy cheat sheet - Guide
- How to copy data from one excel sheet to another - Guide
- Excel hyperlink to another sheet - Guide
- Create new sheet vba - Guide
2 responses
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
22 Apr 2021 à 11:39
22 Apr 2021 à 11:39
Hi Bookman,
I don't see any names in your screenshot. I also don't know how your sheet is called. So for the code below to work I made the following assumptions:
To change the sheet name in the code to match your, you can do so on code line 4.
To change the column letter where the names are located, you can do so on code line 7.
Best regards,
Trowa
I don't see any names in your screenshot. I also don't know how your sheet is called. So for the code below to work I made the following assumptions:
- The sheet with all the data is called Sheet1.
- The column on Sheet1 with all the names is column B.
Sub RunMe()
Dim Header1 As Variant
Sheets("Sheet1").Select
Header1 = Range("A1:J1")
For Each cell In Range("B2:B" & Range("B1").End(xlDown).Row)
cell.EntireRow.Copy
If Not SheetExists(cell.Value) Then
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = cell.Value
Range("A1:J1").Value = Header1
Else
Sheets(cell.Value).Select
End If
Range("A" & Range("A" & Rows.Count).End(xlUp).Row).Offset(1, 0).PasteSpecial
Next cell
End Sub
Function SheetExists(SheetName As String) As Boolean
SheetExists = False
On Error GoTo NoSuchSheet
If Len(Sheets(SheetName).Name) > 0 Then
SheetExists = True
Exit Function
End If
NoSuchSheet:
End Function
To change the sheet name in the code to match your, you can do so on code line 4.
To change the column letter where the names are located, you can do so on code line 7.
Best regards,
Trowa
vcoolio
Posts
1411
Registration date
Thursday 24 July 2014
Status
Contributor
Last seen
6 September 2024
262
23 Apr 2021 à 09:28
23 Apr 2021 à 09:28
Hello Bookman,
If you supply a sample of your actual workbook, it will make solving this for you much, much simpler.
Please upload a sample of your workbook to a free file sharing site such as WeTransfer or Drop Box then post the link to your file back here. Make sure that the sample is an exact replica of your workbook and use dummy data for names or any other more sensitive data.
TrowaD (and any other helpers who may drop in) will be very happy to have something to work/test with.
Thank you Bookman.
Cheerio,
vcoolio.
If you supply a sample of your actual workbook, it will make solving this for you much, much simpler.
Please upload a sample of your workbook to a free file sharing site such as WeTransfer or Drop Box then post the link to your file back here. Make sure that the sample is an exact replica of your workbook and use dummy data for names or any other more sensitive data.
TrowaD (and any other helpers who may drop in) will be very happy to have something to work/test with.
Thank you Bookman.
Cheerio,
vcoolio.