Private Sub Worksheet_Deactivate()
If ThisWorkbook.Sheets("CHANGEOVER FORM").Range("A485").Value > 0 _
Or ThisWorkbook.Sheets("CHANGEOVER FORM").Range("B485").Value > 0 _
Or ThisWorkbook.Sheets("CHANGEOVER FORM").Range("E485").Value > 0 _
Or ThisWorkbook.Sheets("CHANGEOVER FORM").Range("F485").Value > 0 _
Or ThisWorkbook.Sheets("CHANGEOVER FORM").Range("G485").Value > 0 Then
MsgBox "Please either complete the last changeover or delete it"
Me.Activate
End If
End Sub
Private Sub Worksheet_Deactivate()
Dim wsNew As String
Dim ws As Worksheet: Set ws = Worksheets("CHANGEOVER FORM")
Dim aCell As Long, i As Long
Dim aRow As Range
Application.ScreenUpdating = False
wsNew = ActiveSheet.Name
ws.Activate
aCell = ActiveCell.Row
Set aRow = ws.Range("A" & aCell & ":G" & aCell)
For i = 1 To 7
If Not aRow.Value2(1, i) = "" Then
GoTo ComeBack
End If
Next
Worksheets(wsNew).Activate
Application.ScreenUpdating = True
Exit Sub
ComeBack:
MsgBox "Please either complete the last changeover or delete it"
Worksheets("CHANGEOVER FORM").Activate
Application.ScreenUpdating = True
End Sub
Private Sub Worksheet_Deactivate()
Dim i As Long
For i = 485 To Range("A" & Rows.Count).End(xlUp).Row
If Application.CountA(Me.Cells(i, "A").Resize(, 7)) <> 7 Then
MsgBox "Please either complete the last changeover or delete it"
Me.Activate
Exit Sub
End If
Next i
End Sub
Private Sub Worksheet_Deactivate()
Application.EnableEvents = False
Dim T As Long
For T = 1 To 7
If T = 3 Then T = 5
If Cells(ActiveCell.Row, T) = "" Then
MsgBox ("Columns A,B,E,F,G of active row should not be blank.")
Me.Activate
Application.EnableEvents = True
Exit Sub
End If
Next T
Application.EnableEvents = True
End Sub