![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
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! |
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Calgary Canada
Posts: 222
|
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 |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Calgary Canada
Posts: 222
|
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 |
|
|
|
|
|
#4 |
|
Guest
Posts: n/a
|
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!
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: Calgary Canada
Posts: 222
|
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 |
|
|
|
|
|
#6 |
|
Guest
Posts: n/a
|
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! |
|
|
|
#7 |
|
Board Regular
Join Date: Feb 2002
Location: Calgary Canada
Posts: 222
|
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 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|