ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code for MsgBox (https://www.excelbanter.com/excel-programming/372179-code-msgbox.html)

TimN

Code for MsgBox
 
How would I write code for the following situation. Say I have a workbook
with two sheets. Whenever any data hits cell A10 in Sheet2, I would like a
MsgBox to pop up in Sheet1 saying Stop!

Thanks for any suggestions.

Gary''s Student

Code for MsgBox
 
Let's assume that hits means any data is entered into.
In Sheet2's worksheet code enter:


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Cells(10, "A")) Is Nothing Then
Else
Worksheets("Sheet1").Activate
MsgBox ("STOP")
End If
End Sub
--
Gary''s Student

"TimN" wrote:

How would I write code for the following situation. Say I have a workbook
with two sheets. Whenever any data hits cell A10 in Sheet2, I would like a
MsgBox to pop up in Sheet1 saying Stop!

Thanks for any suggestions.


TimN

Code for MsgBox
 
That did it thanks!

One last thing, I would like the spreadsheet to close when the user clicks
OK in the nessage box without saving and without getting the "Would you like
to save changes?" message. Can I do that?


"Gary''s Student" wrote:

Let's assume that hits means any data is entered into.
In Sheet2's worksheet code enter:


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Cells(10, "A")) Is Nothing Then
Else
Worksheets("Sheet1").Activate
MsgBox ("STOP")
End If
End Sub
--
Gary''s Student

"TimN" wrote:

How would I write code for the following situation. Say I have a workbook
with two sheets. Whenever any data hits cell A10 in Sheet2, I would like a
MsgBox to pop up in Sheet1 saying Stop!

Thanks for any suggestions.


Gary''s Student

Code for MsgBox
 
You are very welcome. To quit without the additional question:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Cells(10, "A")) Is Nothing Then
Else
Worksheets("Sheet1").Activate
MsgBox ("STOP")
Application.DisplayAlerts = False
Application.Quit
End If
End Sub


--
Gary''s Student


"TimN" wrote:

That did it thanks!

One last thing, I would like the spreadsheet to close when the user clicks
OK in the nessage box without saving and without getting the "Would you like
to save changes?" message. Can I do that?


"Gary''s Student" wrote:

Let's assume that hits means any data is entered into.
In Sheet2's worksheet code enter:


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Cells(10, "A")) Is Nothing Then
Else
Worksheets("Sheet1").Activate
MsgBox ("STOP")
End If
End Sub
--
Gary''s Student

"TimN" wrote:

How would I write code for the following situation. Say I have a workbook
with two sheets. Whenever any data hits cell A10 in Sheet2, I would like a
MsgBox to pop up in Sheet1 saying Stop!

Thanks for any suggestions.



All times are GMT +1. The time now is 04:45 AM.

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