I'm attaching a link to dummy sheet with data. The first worksheet is titled teacher data, that's my main reference sheet. The second worksheet titled A is what the current code that I'm using does. It sorts the sheet into new individual sheets (students) and then copies all of the data for that student (column B) over to the new sheet.
The third worksheet, title B, is what I need it to do. I need it to copy all of the student info over and update the info on those sheets each time I run the macro. However, I want to include the yellow highlighted section on each created sheet, but I don't want that section to update each time. Essentially, I want it to create the individual sheets and update the only the first 12 rows of each sheet (because the data won't ever be more rows that that.) Is it possible to add to this formula to accomplish this or to use a completely different formula?
Thank you for any help with this. I'm still new to excel and try to figure everything out on my own, but this is a little too complex for me. Please let me know if you need more information (if I need to clarify) or anything else. Thanks!
Teacher Data.xltm.zip
This is the current code that I'm using (and it works perfectly to sort and split the data into newly created sheets, but I need to only update certain cells because I need to write data on sheet B in the highlighted area that doesn't get deleted each time the top portion of data (12 rows) updates.
Sub Split_Sht_in_Separate_Shts()
'### 17-03-2019 ###
Const FirstC As String = "A" '1st column
Const LastC As String = "AJ" 'last column
Const sCol As String = "B" '<<< Criteria in Column B
Const shN As String = "Mishler" '<<< Source Sheet
Dim ws As Worksheet, ws1 As Worksheet
Set ws = Sheets(shN)
Dim rng As Range
Dim r As Long, c As Long, x As Long, r1 As Long
Application.ScreenUpdating = False
r = ws.Range(FirstC & ":" & LastC).Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
c = ws.Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column + 2
Set rng = ws.Range(ws.Cells(1, FirstC), ws.Cells(r, LastC))
ws.Range(sCol & ":" & sCol).Copy
ws.Cells(1, c).PasteSpecial xlValues
Application.CutCopyMode = False
ws.Cells(1, c).Resize(r).RemoveDuplicates Columns:=1, Header:=xlYes
r1 = ws.Cells(Rows.Count, c).End(xlUp).Row
ws.Cells(1, c).Resize(r1).Sort Key1:=ws.Cells(1, c), Header:=xlYes
ws.AutoFilterMode = False
Application.DisplayAlerts = False
For x = 2 To r1
For Each ws1 In Sheets
If ws1.Name = ws.Cells(x, c) Then ws1.Delete
Next
Next
Application.DisplayAlerts = True
For x = 2 To r1
ws.Range(ws.Cells(1, sCol), ws.Cells(r, sCol)).AutoFilter Field:=1, Criteria1:=ws.Cells(x, c)
Set ws1 = Worksheets.Add(after:=Worksheets(Worksheets.Count))
ws1.Name = ws.Cells(x, c).Value
rng.SpecialCells(xlCellTypeVisible).Copy
Range("A1").PasteSpecial Paste:=xlPasteFormats
Range("A1").PasteSpecial Paste:=xlPasteColumnWidths
Range("A1").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Next x
With ws
.AutoFilterMode = False
.Cells(1, c).Resize(r).ClearContents
.Activate
.Range("A1").Select
End With
Application.ScreenUpdating = True
End Sub
The third worksheet, title B, is what I need it to do. I need it to copy all of the student info over and update the info on those sheets each time I run the macro. However, I want to include the yellow highlighted section on each created sheet, but I don't want that section to update each time. Essentially, I want it to create the individual sheets and update the only the first 12 rows of each sheet (because the data won't ever be more rows that that.) Is it possible to add to this formula to accomplish this or to use a completely different formula?
Thank you for any help with this. I'm still new to excel and try to figure everything out on my own, but this is a little too complex for me. Please let me know if you need more information (if I need to clarify) or anything else. Thanks!
Teacher Data.xltm.zip
This is the current code that I'm using (and it works perfectly to sort and split the data into newly created sheets, but I need to only update certain cells because I need to write data on sheet B in the highlighted area that doesn't get deleted each time the top portion of data (12 rows) updates.
Sub Split_Sht_in_Separate_Shts()
'### 17-03-2019 ###
Const FirstC As String = "A" '1st column
Const LastC As String = "AJ" 'last column
Const sCol As String = "B" '<<< Criteria in Column B
Const shN As String = "Mishler" '<<< Source Sheet
Dim ws As Worksheet, ws1 As Worksheet
Set ws = Sheets(shN)
Dim rng As Range
Dim r As Long, c As Long, x As Long, r1 As Long
Application.ScreenUpdating = False
r = ws.Range(FirstC & ":" & LastC).Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
c = ws.Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column + 2
Set rng = ws.Range(ws.Cells(1, FirstC), ws.Cells(r, LastC))
ws.Range(sCol & ":" & sCol).Copy
ws.Cells(1, c).PasteSpecial xlValues
Application.CutCopyMode = False
ws.Cells(1, c).Resize(r).RemoveDuplicates Columns:=1, Header:=xlYes
r1 = ws.Cells(Rows.Count, c).End(xlUp).Row
ws.Cells(1, c).Resize(r1).Sort Key1:=ws.Cells(1, c), Header:=xlYes
ws.AutoFilterMode = False
Application.DisplayAlerts = False
For x = 2 To r1
For Each ws1 In Sheets
If ws1.Name = ws.Cells(x, c) Then ws1.Delete
Next
Next
Application.DisplayAlerts = True
For x = 2 To r1
ws.Range(ws.Cells(1, sCol), ws.Cells(r, sCol)).AutoFilter Field:=1, Criteria1:=ws.Cells(x, c)
Set ws1 = Worksheets.Add(after:=Worksheets(Worksheets.Count))
ws1.Name = ws.Cells(x, c).Value
rng.SpecialCells(xlCellTypeVisible).Copy
Range("A1").PasteSpecial Paste:=xlPasteFormats
Range("A1").PasteSpecial Paste:=xlPasteColumnWidths
Range("A1").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Next x
With ws
.AutoFilterMode = False
.Cells(1, c).Resize(r).ClearContents
.Activate
.Range("A1").Select
End With
Application.ScreenUpdating = True
End Sub