stevembe
02-18-2013, 02:09 AM
Hoping someone can help.
I have a worksheet that is using the following code that forces people to complete cells:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Sheets("Sheet1")
If WorksheetFunction.CountA(.Range("A1,B6,C4")) <> 3 Then
MsgBox "You must complete A1, B6, C4 "
Cancel = True
End If
End With
End Sub
Is there anyway of adapting this so the message reads:
“You must complete cells A1, B6, C4 unless you opened the workbook to view only”
Then two option buttons saying OK and View File Only. OK will take you back to the sheet to populate the mandatory cells whereas the other exits the workbook without saving any changes.
I have a worksheet that is using the following code that forces people to complete cells:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Sheets("Sheet1")
If WorksheetFunction.CountA(.Range("A1,B6,C4")) <> 3 Then
MsgBox "You must complete A1, B6, C4 "
Cancel = True
End If
End With
End Sub
Is there anyway of adapting this so the message reads:
“You must complete cells A1, B6, C4 unless you opened the workbook to view only”
Then two option buttons saying OK and View File Only. OK will take you back to the sheet to populate the mandatory cells whereas the other exits the workbook without saving any changes.