Sub ProtectWorksheet_Initiated_By_School()
'
'Go back to sheet 1 from the instructions sheet
Sheets(1).Select 'This selects sheet 1 no matter what it is called
'Brand new section. we dont want them to protect if they havent done everything neccessary
Dim i As Long, lrow As Long
With Worksheets(1)
lrow = .Range("H" & .Rows.Count).End(xlUp).Row 'H is the row of JobFamily
'For To Clause. When the counter i is 7 (The first actual value.
'to the number of the row we are on.
'The final value of the of the i counter in the above loop will be after 1row.
' i starts on row 7 and finishes on the end row
For i = 7 To lrow ' + 1
'If job title is not null and New Grade is 0 then
If .Range("H" & i).Value <> "" And .Range("K" & i).Value = "0" Then
MsgBox ("Please complete all the new posts")
Exit Sub
'And now we have to do the last checks to make sure that the New Grade is correct for the Job Family Desc
'This is an issue if the New grade is changed BEFORE the job family description is changed.
ElseIf .Range("I" & i).Value Like "BPS*" And UBound(Filter(Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"), .Range("J" & i).Value)) < 0 Then
MsgBox ("BPS has an incorrect grade. Please amend and continue")
Exit Sub
ElseIf .Range("I" & i).Value Like "CAT*" And UBound(Filter(Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"), .Range("J" & i).Value)) < 0 Then
MsgBox ("CAT has an incorrect grade. Please amend and continue")
Exit Sub
ElseIf .Range("I" & i).Value Like "CAM*" And UBound(Filter(Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"), .Range("J" & i).Value)) < 0 Then
MsgBox ("CAM has an incorrect grade. Please amend and continue")
Exit Sub
ElseIf .Range("I" & i).Value Like "CAH*" And UBound(Filter(Array("6", "7", "8", "9", "10", "11", "12", "13", "14"), .Range("J" & i).Value)) < 0 Then
MsgBox ("CAH has an incorrect grade. Please amend and continue")
Exit Sub
ElseIf .Range("I" & i).Value Like "SCI*" And UBound(Filter(Array("4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"), .Range("J" & i).Value)) < 0 Then
MsgBox ("SCI has an incorrect grade. Please amend and continue")
Exit Sub
ElseIf .Range("I" & i).Value Like "SPD*" And UBound(Filter(Array("8", "9", "10", "11", "12"), .Range("J" & i).Value)) < 0 Then
MsgBox ("SPD has an incorrect grade. Please amend and continue")
Exit Sub
ElseIf .Range("I" & i).Value Like "SUS*" And UBound(Filter(Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"), .Range("J" & i).Value)) < 0 Then
MsgBox ("SUS has an incorrect grade. Please amend and continue")
Exit Sub
ElseIf .Range("I" & i).Value Like "TAL*" And UBound(Filter(Array("5", "6", "7", "8", "9"), .Range("J" & i).Value)) < 0 Then
MsgBox ("TAL has an incorrect grade. Please amend and continue")
Exit Sub
ElseIf .Range("I" & i).Value Like "TRA*" And UBound(Filter(Array("6", "7", "8", "9", "10", "11", "12", "13", "14"), .Range("J" & i).Value)) < 0 Then
MsgBox ("TRA has an incorrect grade. Please amend and continue")
Exit Sub
The bit in the middle isn the bit that doest work
Bookmarks