ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional Message Box (https://www.excelbanter.com/excel-programming/336343-conditional-message-box.html)

Adam Harding

Conditional Message Box
 
I am after using a before close statement to check a cell's value and show a
message box if true. This would apply across all of my worksheets.

I.E.

If C1 = False

Then Display C1 needs to be True

But then still let them close. As an aside is there any way to make sure a
front worksheet opens no matter on which worksheet it is closed?

Many thanks.

Bob Phillips[_6_]

Conditional Message Box
 

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Worksheets("Sheet1").Range("A1").Value = False Then
MsgBox "Invalid value"
End If
End Sub

Private Sub Workbook_Open()
Worksheets("Sheet1").Activate
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--
HTH

Bob Phillips

"Adam Harding" wrote in message
...
I am after using a before close statement to check a cell's value and show

a
message box if true. This would apply across all of my worksheets.

I.E.

If C1 = False

Then Display C1 needs to be True

But then still let them close. As an aside is there any way to make sure

a
front worksheet opens no matter on which worksheet it is closed?

Many thanks.




Adam Harding

Conditional Message Box
 
Cheers Bob

"Bob Phillips" wrote:


Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Worksheets("Sheet1").Range("A1").Value = False Then
MsgBox "Invalid value"
End If
End Sub

Private Sub Workbook_Open()
Worksheets("Sheet1").Activate
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--
HTH

Bob Phillips

"Adam Harding" wrote in message
...
I am after using a before close statement to check a cell's value and show

a
message box if true. This would apply across all of my worksheets.

I.E.

If C1 = False

Then Display C1 needs to be True

But then still let them close. As an aside is there any way to make sure

a
front worksheet opens no matter on which worksheet it is closed?

Many thanks.






All times are GMT +1. The time now is 08:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com