MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Feb 25th, 2002, 12:06 PM   #1
Guest
 
Posts: n/a
Default

Hi All!

I'd like to create the following-

I have a cell (D31) that is computed via formula that depends on the values in numerous other cells. It is a dollar amount and I would like a message box to pop-up and say "Target Reached" when D31 exceeds 1,000,000. So, when I change the values in the cells that change D31, D31 will eventually exceed 1,000,000, and then the message box should appear. Any help is greatly appreciated!
  Reply With Quote
Old Feb 25th, 2002, 12:25 PM   #2
Tom Morales
Board Regular
 
Join Date: Feb 2002
Location: Richland, Washington
Posts: 91
Default

Yo, Anon
Right-click the worksheet tab, select "View Code", and insert this macro:
Private Sub Worksheet_Change(ByVal Target As Range)
If [d31].Value > 1000000 Then _
MsgBox "Target Reached."
End Sub
Tom

[ This Message was edited by: Tom Morales on 2002-02-25 11:26 ]
Tom Morales is offline   Reply With Quote
Old Feb 25th, 2002, 12:26 PM   #3
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

Sorry, Tom, posted just after you

Try the following: -

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Count > 1 Then Exit Sub
If Cells(31, 4).Value > 1000000 Then MsgBox "Target Reached!"

End Sub

To enter the code, right-click on the sheet tab where you want the message to appear, select 'View Code', this will open up the VB editor and just paste the above into the right-hand code window.


[ This Message was edited by: Mudface on 2002-02-25 11:28 ]
Mudface is offline   Reply With Quote
Old Feb 25th, 2002, 12:47 PM   #4
Guest
 
Posts: n/a
Default

Not working...I think because those cells that I used to calculate D31 are derived from other cells, etc. Therefore, when D31 ends up being larger than 1,000,000, nothing happens....any workarounds? sorry for the confusion, I appreciate the help.
  Reply With Quote
Old Feb 25th, 2002, 01:05 PM   #5
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

Hmm, sorry, both work OK for me, have you pasted the code into the right place?
Mudface is offline   Reply With Quote
Old Feb 25th, 2002, 01:53 PM   #6
Guest
 
Posts: n/a
Default

Yeah, I think the code is in the right place...the thing is that I can get your code to work if for example, I have the following scenario:

C2*C3= C31, where I can manually enter numbers into C2 & C3. Then, if I enter 10000 in to C2 and 10000 into C3, C31=100,000,000. In this case, I do get the message box as I would like it. The problem is, this is not how my model is set up. In my model, C2 & C3 are calculated based on other values in other cells, and in addition to this, there is no manual entry of numbers anywhere...combo boxes are used. So, I am not sure if there is some method to deal with all of this confusion or not! I'm sure you are thoroughly confused at this point! But if by chance you have any ideas...GREAT!
  Reply With Quote
Old Feb 25th, 2002, 06:01 PM   #7
Tom Morales
Board Regular
 
Join Date: Feb 2002
Location: Richland, Washington
Posts: 91
Default

Jeez, Anon, you're right. You learn something new every day.

I think the way around this is to assign the macro to your combobox or comboboxes, such as:

Private Sub ComboBox1_Change()
If [d31] > 1000000 Then _
MsgBox "Target Reached"
End Sub

I tried it, and it works.

Tom
Tom Morales is offline   Reply With Quote
Old Feb 26th, 2002, 08:31 AM   #8
Guest
 
Posts: n/a
Default

Thanks, now what if I have like 5 different combo boxes instead of just one? How can I incorporate them into the code to cover all bases? I appreciate it...
  Reply With Quote
Old Feb 26th, 2002, 12:30 PM   #9
Tom Morales
Board Regular
 
Join Date: Feb 2002
Location: Richland, Washington
Posts: 91
Default

If you're using comboboxes from the controls toolbar, you would have to add that code to each combobox or, alternately, you could put the code on a regular module, and have each combobox call that sub on its change. eg, on your worksheet module, put:

Private Sub ComboBox1_Change()
whatever
End Sub

Private Sub ComboBox2_Change()
whatever
End Sub

...and so on.

And on your regular code module:

Sub whatever
If [d31].value > 1000000 Then _
MsgBox "Target Reached"
End Sub

If you're using comboboxes from the forms toolbar, simply link each combobox to sub "whatever".
Tom


[ This Message was edited by: Tom Morales on 2002-02-26 11:43 ]
Tom Morales is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 06:22 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes