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 Apr 25th, 2002, 02:17 AM   #1
inarbeth
Board Regular
 
Join Date: Apr 2002
Location: Wivenhoe, England
Posts: 877
Default

On a worksheet dates are to be inserted in cells C7 and C13. In C14 is a calculation to give C13 minus C7 provided both C7 and C13 contain dates and C13 is greater than C7 (i.e a number for date difference).
I already use data validation to control input in C7, C13 and C14. Users can also overwrite the formula in C14 in certain cases (the workbook is read-only so the formula revives when they re-open).

I want to activate different message boxes depending upon the date put in to C13 and upon the figure in C14. In addition rather like the warning feature in Data Validation users can ignore the messages so I only want them to appear when relevant cells are the active cell. In order of priority the messages I want are:
1. If the date in C13 is more than 91 but less than or equal to 181 days after today's date, Message 1 appears.
2. If the date in C13 is more than 181 days after today's date, Message 2 appears.

Messages 1 and 2 are to appear only if the entry has been direcly into C13 (NB I use a data validation dropdown box in C13 but the user can insert another date if required).

3. If the value in C14 is more than 91 but less than or equal to 181, message 3 appears.
4. If the value in C14 is more than 181, message 4 appears.

Messages 3 and 4 are to appear if the value of C14 is created either as a result of inputting dates in C7 or C13 or if the user overtypes C14 with their own figure. I think this means when any of C7, C13 or C14 is the ActiveCell.

The messages should not appear at other times. I have tried using Target.Address = C13 syntax but have got stuck and am on the point of shelling out for a book on VBA for Excel (probably a good investment but that's another story).

Can you also please include the code to change the title in the pop up message boxes to Title 1, Title 2 etc.

I have given cells C7, C13 and C14 names (let us call them Name1, Name2 and Name3 for the sake of example) and so would prefer to use these names rather than the cell references so that I can insert rows above 14 if necessary without having to re-do the code for the messages.
Many thanks in advance.
inarbeth is offline   Reply With Quote
Old Apr 25th, 2002, 02:14 PM   #2
inarbeth
Board Regular
 
Join Date: Apr 2002
Location: Wivenhoe, England
Posts: 877
Default

I can't offer deification unlike buntykins (Whoever answers this will be a god!!!!!!!)but can anyone help with this please? Will eternal gratitude be sufficient?
inarbeth is offline   Reply With Quote
Old Apr 25th, 2002, 02:32 PM   #3
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

In a sheet module (not a regular code module) try the following:

'-------------
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

If Target.Address(False, False) = "C7" Then
If Target.Offset(7, 0) > 91 And _
Target.Offset(7, 0) <= 181 Then MsgBox "Three", , "Title3"
If Target.Offset(7, 0) > 181 Then MsgBox "Four", , "Title4"
End If

If Target.Address = "$C$13" Then
If Target.Value > Date + 91 And _
Target.Value <= Date + 181 Then MsgBox "One", , "Title1"
If Target.Value > Date + 181 Then MsgBox "Two", , "Title2"
End If

If Target.Address = "$C$14" Then
If Target.Value > 91 And _
Target.Value <= 181 Then MsgBox "Three", , "Title3"
If Target.Value > 181 Then MsgBox "Four", , "Title4"
End If

End Sub
'-----------------

Not elegant, and I'm not sure it meets your needs, but it may get you started.

Bye,
Jay

P.S. I am only in this for eternal gratitude!
Jay Petrulis is offline   Reply With Quote
Old Apr 25th, 2002, 02:37 PM   #4
inarbeth
Board Regular
 
Join Date: Apr 2002
Location: Wivenhoe, England
Posts: 877
Default

Thanks Jay, I'll try this out. Eternal gratitude is yours!
inarbeth is offline   Reply With Quote
Old Apr 30th, 2002, 01:38 AM   #5
inarbeth
Board Regular
 
Join Date: Apr 2002
Location: Wivenhoe, England
Posts: 877
Default

Thanks Jay. I have been able to create the required messages in Excel 2000.
Two questions, if I may:
1. I have Excel 2000 at home and Excel 97 SR-2 in the office. When I use the Data Validation dropdown in C13 to insert a date more than 91 days away no message appears in Excel 97 but it does in Excel 2000. If I go back into C13 and edit the date in the formula bar in Excel 97 the macro works. Can anyone explain that?

2. Jay, is there a reason why you used Offset to tie in cells C7 and C14 as opposed to absolute references?
inarbeth is offline   Reply With Quote
Old Apr 30th, 2002, 10:49 AM   #6
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Hi Ian,

I am unsure why this is not working for you. It was written with Excel 97, so it should work. Possibly it is working, but the triggers are not met. They may need to be reevaluated.

For question 2, either way will work. If you prefer the explicit declarations, change to Range("C14") and the like. They should work with no problem.

I will take another look at this, but it is working on my system.

Jay

EDIT: I didn't see the point where it works, but not on the Drop Down. I'll check that.

[ This Message was edited by: Jay Petrulis on 2002-04-30 09:51 ]
Jay Petrulis is offline   Reply With Quote
Old Apr 30th, 2002, 02:02 PM   #7
inarbeth
Board Regular
 
Join Date: Apr 2002
Location: Wivenhoe, England
Posts: 877
Default

Thanks Jay. I have double-checked and confirm my results. I don't think it is relevant but in the office (Excel 97) we use a document management system called PDDOCS that interferes with some Excel functionality (but not so far as I am aware within a sheet).
inarbeth 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 09:59 AM.


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