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 May 13th, 2002, 06:13 PM   #1
ExcelNovice
Board Regular
 
ExcelNovice's Avatar
 
Join Date: May 2002
Posts: 485
Default

This forum is a good thing.
I know a genius will solve this problem in no time.

Cells E3:E6 are populated with numbers, so too are cells F3:F6.
First I want to auto sort the following range B3:F6, sorting by E3:E6 whenever a value in E3:E6 is changed.
Second I want to auto sort the following range B3:F6, sorting by F3:F6 whenever a value in F3:F6 is changed.

Then, I want to do this: Using macro (or any other way possible), determine if E3>E4 and if so, place D3 in cell H3 and D4 in cell H4.
If E3=E4, then determine if F3>F4 and if so then place D3 in H3 & D4 in H4.
If F3
That's it!
I hope this is not too crazy. Thanks in advance.
ExcelNovice is offline   Reply With Quote
Old May 13th, 2002, 06:26 PM   #2
Yogi Anand
MrExcel MVP
 
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
Default

Quote:
On 2002-05-13 17:13, ExcelNovice wrote:
This forum is a good thing.
I know a genius will solve this problem in no time.

Cells E3:E6 are populated with numbers, so too are cells F3:F6.
First I want to auto sort the following range B3:F6, sorting by E3:E6 whenever a value in E3:E6 is changed.
Second I want to auto sort the following range B3:F6, sorting by F3:F6 whenever a value in F3:F6 is changed.

Then, I want to do this: Using macro (or any other way possible), determine if E3>E4 and if so, place D3 in cell H3 and D4 in cell H4.
If E3=E4, then determine if F3>F4 and if so then place D3 in H3 & D4 in H4.
If F3
That's it!
I hope this is not too crazy. Thanks in advance.
1) For the first part you need a VBA
solution

2) for the seconfd part, try the following formulas

in cell H3 ... =IF($E$3>$E$4,D3,IF($E$3=$E$4,IF($F$3>$F$4,D3,"whateverElse")))
in cell H4 ... =IF($E$3>$E$4,D4,IF($E$3=$E$4,IF($F$3>$F$4,D4,"whateverElse")))

I am sure these can be simplified, but this will get you started.

__________________
Regards!

Yogi Anand, D.Eng, P.E.
Energy Efficient Building Network LLC
www.energyefficientbuild.com
Yogi Anand is offline   Reply With Quote
Old May 13th, 2002, 06:31 PM   #3
ExcelNovice
Board Regular
 
ExcelNovice's Avatar
 
Join Date: May 2002
Posts: 485
Default

Thanks man. I'm willing to give it a shot. Let's see if someone else can give me some more ideas.
ExcelNovice is offline   Reply With Quote
Old May 13th, 2002, 06:34 PM   #4
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

I tried to crank the whole nine yards in vba. Right click on the sheet tab in question, click 'view code' and paste the following:


Private Sub Worksheet_Change(ByVal Target As Range)
Dim cl As Range
Application.EnableEvents = False
If Not application.Intersect(Target, [e3:f6]) Is Nothing Then
If Not application.Intersect(Target, [e3:e6]) Is Nothing Then _
[b3:f6].Sort Key1:=Range("E3"), Order1:=xlAscending, Header:=xlGuess
If Not application.Intersect(Target, [f3:f6]) Is Nothing Then _
[b3:f6].Sort Key1:=Range("f3"), Order1:=xlAscending, Header:=xlGuess
If [e3].Value > [e4].Value Then
[h3].Value = [d3].Value
[h4].Value = [d4].Value
ElseIf [e3].Value = [e4].Value Then
If [f3].Value > [f4].Value Then
[h3].Value = [d3].Value
[h4].Value = [d4].Value
End If
End If
End If
Application.EnableEvents = True
End Sub


This does a sort, in ascending order, not sure which way you wanted to go, but if need be (much like my poor dog) it can be fixed.
_________________
Cheers, NateO

[ This Message was edited by: nateo on 2002-05-13 19:19 ]
NateO is offline   Reply With Quote
Old May 13th, 2002, 06:39 PM   #5
dimrod
 
Join Date: May 2002
Posts: 73
Default

You see. It didn't need any geniuses.
dimrod is offline   Reply With Quote
Old May 13th, 2002, 06:56 PM   #6
ExcelNovice
Board Regular
 
ExcelNovice's Avatar
 
Join Date: May 2002
Posts: 485
Default

You're all geniuses.

By the way NateO, I place the code in as you suggested but I cannot get it to work. Is there something else that I need to do? Even when the cell values change nothing happens.

Sorry for the trouble.

ExcelNovice is offline   Reply With Quote
Old May 13th, 2002, 07:04 PM   #7
dimrod
 
Join Date: May 2002
Posts: 73
Default

Quote:
On 2002-05-13 17:56, ExcelNovice wrote:
You're all geniuses.
The one-eyed man in the land of the blind..... etc.
dimrod is offline   Reply With Quote
Old May 13th, 2002, 07:16 PM   #8
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

No trouble. You did indeed get the code in the correct sheet module as described above (Right click on the sheet tab (sheet with data), click 'view code' and paste the following)....Perhaps your events aren't enabled. Put the following in any normal module, run it and try again:

Code:
sub ck()
application.enableevents = true
end sub
Hope this helps.

_________________
Cheers, NateO

[ This Message was edited by: NateO on 2002-05-13 18:25 ]
NateO is offline   Reply With Quote
Old May 13th, 2002, 07:46 PM   #9
ExcelNovice
Board Regular
 
ExcelNovice's Avatar
 
Join Date: May 2002
Posts: 485
Default

Call me stupid, but I just can't get this thing to work. I did everything you said...then I realize the problem:

The macro is running but only if I change the value in the cell by clicking on the cell and entering new values. That's not what I'm doing. The value in the cells are actually changing when I change the values in cells on a totally different sheet.

I thought the macro would run when the value is changed, nevermind the fact that the change is not done directly. Guess I just don't know this thing.

Nateo can you help please?
ExcelNovice is offline   Reply With Quote
Old May 17th, 2002, 02:02 PM   #10
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

ExcelNovice, did you notice my private message way back when? I'd be more than happy to help. I could show you one of a few ways to accomplish this. If you're still interested, to make this more fruitful, name the worksheet that the entry is made, and the range the entry is made, and the name of the sheet where the data is manipulated.
__________________
Regards,
Nate Oliver
Microsoft Excel MVP
Nate's Excel Blog
NateO 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 05:27 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