Message Box Prompt

G

Guest

Guest
I'd like to create the following situation (VBA)

I have a cell (C4) that is calculated based on values contained in other cells. What I would like is to have a message box appear when the value in C4 exceeds 10,000. Any suggestions? Thanks!
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
hi,
put this code in the sheet:
''''''''''''''''''''''
Private Sub Worksheet_Change(ByVal Target As Range)
If ActiveSheet.Range("C4").Value > 10000 Then MsgBox "The value in C4 exceeds 10,000"
End Sub

'''''''''''''''''''''''''''''''''''''''''
good luck
 
Upvote 0
or try:
'''''''''''''''''''''''
Private Sub Worksheet_Change(ByVal Target As Range)

If Sheets(Sheet_Name).Range("C4").Value > 10000 Then MsgBox "The value in C4 exceeds 10,000"
End Sub
''''''''''''''''''''''''''''''
where Sheet_Name is the sheet that contains the C4.
Good luck
Hamid
 
Upvote 0
Hmmm...I have tried both, with no luck. Do I put this in the sheet or as a module. Also, the cell (C4) that I need to determine the prompt is calculated based on the addition of two other cells, so I'm not sure if this is the problem. Or maybe there are additional steps the the code you offered that I have not entered? Any sugggestions? Thanks again!
 
Upvote 0
please put these code in "SheetChange" event for "Workbook" object:
''''''''''''''''''''''
Sheet_Name = "Sheet1"
If Sheets(Sheet_Name).Range("C4").Value > 10000 Then MsgBox "The value in C4 exceeds 10,000"
'''''''''''''''''''''''''''''''''''
also no problem about C4.

Hamid
 
Upvote 0
I apologize for my ignorance, but I am still having trouble! I'm not really sure what the following means:

please put these code in "SheetChange" event for "Workbook" object:

Can you explain this in more detail? I really appreciate your help!
 
Upvote 0
may be it is my fault. I am not good in English. anyway,
in VBA:
from "VBAProject" window choose "microsoft Excel Objects" folder.
from this folder choose "thisworkbook" object.
now paste this code:
'''''''''''''''
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Sheet_Name = "Sheet1"
If Sheets(Sheet_Name).Range("C4").Value > 10000 Then MsgBox "The value in C4 exceeds 10,000"

End Sub
'''''''''''''''''''''
if I have your Email address, I can send the program.
hshahbaazi@chem.susc.ac.ir
best wishes
Hamid
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,306
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top