Sub Update_Student_Info()
Dim wsRost As Worksheet
Dim wsStud As Worksheet
Dim wsStar As Worksheet
Set wsRost = Sheets("Roster")
Set wsStud = Sheets("Student Info")
Set wsStar = Sheets("Start Here")
Set wsBody = Sheets("Body Fat")
'On Error GoTo BadRoster 'In case bad or wrong text file and can't find NAME in col A
'get row number of first student name ie 2 rows below occurance of NAME in roster col A
Firstrow = Application.WorksheetFunction.Match("NAME", wsRost.Range("A1:A250"), 0) + 2
wsStud.Range("A6:D6,A11:Z250").ClearContents
wsStar.Range("B4:B27").ClearContents
wsBody.Range("E3:H27,J3:L27,P3:R27,V3:X27").ClearContents
'get row number of last student name ie last data in roster col H
Lastrow = wsRost.Range("H65536").End(xlUp).Row
Studrow = 10
With wsRost
For r = Firstrow To Lastrow Step 3 'increment 3 since names 3 rows apart
Studrow = Studrow + 1
'check for trailing comma in what should be 2nd initial column - if yes, = suffix so delete cell & shift data
If Right$(.Cells(r, 3), 1) = "," Then .Cells(r, 3).Delete Shift:=xlToLeft
'check for missing 2nd initial - if missing, insert cell & shift data
If Not Application.WorksheetFunction.IsText(.Cells(r, 4)) Then .Cells(r, 4).Insert Shift:=xlToRight
ShiftInitial = 0
RankTitle = .Cells(r, 1).Value
If RankTitle = "" Then RankTitle = "???"
wsStud.Cells(Studrow, 1).Value = RankTitle
'populate cells in Student Info
Surname = .Cells(r, 2).Value
If Not Right$(Surname, 1) = "," Then Surname = Surname & ","
wsStud.Cells(Studrow, 2).Value = Surname 'surname
Forename = .Cells(r, 3).Value & " " & .Cells(r, 4).Value 'Forename + initial
wsStud.Cells(Studrow, 3).Value = Forename 'Forename & initial
wsStud.Cells(Studrow, 5).Value = .Cells(r, 5).Value 'SSN
wsStud.Cells(Studrow, 6).Value = .Cells(r, 6).Value 'BR
wsStud.Cells(Studrow, 7).Value = .Cells(r, 7).Value 'CL
wsStud.Cells(Studrow, 8).Value = .Cells(r, 8).Value 'UIC
wsStud.Cells(Studrow, 9).Value = .Cells(r, 9).Value 'Rate
'Username
wsStud.Cells(Studrow, 4).Value = .Cells(r + 1, 2).Value & " " & _
.Cells(r + 1, 3).Value & " " & .Cells(r + 1, 4).Value
Next r
End With
GoTo Out
BadRoster:
Response = MsgBox("Cannot update Student Info - Roster not compatible.", vbOKOnly, "Sorry!")
On Error GoTo 0
Out:
Set wsRost = Nothing
Set wsStud = Nothing
Set wsStar = Nothing
Set wsBody = Nothing
Application.ScreenUpdating = True
Call Insert_Title
End Sub
Sub class_info()
Application.ScreenUpdating = False
Sheets("Roster").Select
Rows("1:4").Select
Selection.Find(What:="CDP:", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 1).Select
Selection.Copy
Sheets("Student Info").Select
Range("E6").Select
ActiveSheet.Paste
Sheets("Roster").Select
Rows("10:15").Select
Selection.Find(What:="CIN:", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 1).Select
Selection.Copy
Sheets("Student Info").Select
Range("A6").Select
ActiveSheet.Paste
Sheets("Roster").Select
Rows("13:19").Select
Selection.Find(What:="class", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
If ActiveCell.Offset(1, 0).Value = "" Then
ActiveCell.Offset(2, 0).Select
Selection.Copy
Sheets("Student Info").Select
Range("B6").Select
ActiveSheet.Paste
Else
ActiveCell.Offset(1, 0).Select
Selection.Copy
Sheets("Student Info").Select
Range("B6").Select
ActiveSheet.Paste
End If
Sheets("Roster").Select
Rows("13:19").Select
Selection.Find(What:="work", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
If ActiveCell.Offset(1, 0).Value = "" Then
ActiveCell.Offset(2, 0).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Student Info").Select
Range("C6").Select
ActiveSheet.Paste
Else
ActiveCell.Offset(1, 0).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Student Info").Select
Range("C6").Select
ActiveSheet.Paste
End If
Sheets("Roster").Select
Cells.Find(What:="center", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
If ActiveCell.Offset(1, 0).Value = "" Then
ActiveCell.Offset(2, 0).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Student Info").Select
Range("D6").Select
ActiveSheet.Paste
Else
ActiveCell.Offset(1, 0).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Student Info").Select
Range("D6").Select
ActiveSheet.Paste
End If
Worksheets("Start Here").Select
End Sub