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 Mar 14th, 2002, 11:40 AM   #1
bobmc
Board Regular
 
Join Date: Mar 2002
Posts: 142
Default

I'd like to program three cells so that if data is entered into any one of them, the other two become blank.

Any help?
bobmc is offline   Reply With Quote
Old Mar 14th, 2002, 01:04 PM   #2
Tom Morales
Board Regular
 
Join Date: Feb 2002
Location: Richland, Washington
Posts: 91
Default

Bobmc -
Try something like:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" And
Target.Formula <> "" Then [A2,A3].ClearContents
If Target.Address = "$A$2" And Target.Formula <> "" Then [A1,A3].ClearContents
If Target.Address = "$A$3" And Target.Formula <> "" Then [A1,A2].ClearContents
End Sub

Right-click your worksheet tab, select "View Code" and put the code there.
Tom

[ This Message was edited by: Tom Morales on 2002-03-14 12:05 ]
Tom Morales is offline   Reply With Quote
Old Mar 14th, 2002, 01:20 PM   #3
bobmc
Board Regular
 
Join Date: Mar 2002
Posts: 142
Default

Thanks for the reply!!!

It came close to working...

However, when I tab out of a given cell after entering anything <>"", the other cell that already has an entry doesn't 'CLEARCONTENTS' until I tab back into the cell I've just entered a value in.
Also, the bottom-most of the three cells in question doesn't respond well...it wants to override entries into cells above it.

Any more info on this is appreciated!
bobmc is offline   Reply With Quote
Old Mar 14th, 2002, 01:26 PM   #4
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

You could try a slight variation on Tom's code as below: -

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then [A2,A3].ClearContents
If Target.Address = "$A$2" Then [A1,A3].ClearContents
If Target.Address = "$A$3" Then [A1,A2].ClearContents
End Sub
Mudface is offline   Reply With Quote
Old Mar 14th, 2002, 01:37 PM   #5
bobmc
Board Regular
 
Join Date: Mar 2002
Posts: 142
Default

Again, close...

This time, the top two of the three cells in question don't keep an entry. It erases itself as soon as I enter data.

The bottom of the three cells holds its entry. But when I enter into one of the two cells above it, then hit tab, the bottom one doesn't go away and there's still no entry above.

Hmmm.
bobmc is offline   Reply With Quote
Old Mar 14th, 2002, 01:51 PM   #6
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

I'm confused now. You asked for code that would blank out two cells from a group of three, if an entry is made into the other cell. Mine does that, and I'm presuming Tom's does too. Could you reiterate exactly what you want?
Mudface is offline   Reply With Quote
Old Mar 14th, 2002, 01:54 PM   #7
bobmc
Board Regular
 
Join Date: Mar 2002
Posts: 142
Default

OK...I'M GETTING CLOSER!!!

Here's the deal...

Instead of the code header being SELECTION_CHANGE, I made it simply CHANGE. That solves the problem of entries not sticking. Now, here's the last little bug...
If there's an entry in the bottom of the three cells, and I put an entry into the middle cell, the bottom cell keeps its entry rather than disappearing. Everything else works!

Any last suggestions?

Thanks.
bobmc is offline   Reply With Quote
Old Mar 14th, 2002, 02:00 PM   #8
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

Hmmm. My code works fine for me, whenever an entry is made in any of the cells the other two are blanked regardless of where the entry is made. Also, it already is using the Change event rather than SelectionChange. Copy and paste the code I gave you above into your worksheet and try that.
Mudface is offline   Reply With Quote
Old Mar 14th, 2002, 02:05 PM   #9
bobmc
Board Regular
 
Join Date: Mar 2002
Posts: 142
Default

MY BAD...

Found a letter that was off. Sorry for the confusion...and...

THANK YOU FOR YOUR WISDOM!! IT WORKS GREAT!
bobmc is offline   Reply With Quote
Old Mar 14th, 2002, 02:07 PM   #10
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

Hehe, phew . Good luck with the rest .
Mudface 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:31 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