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 18th, 2002, 02:13 PM   #1
viper
Board Regular
 
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
Default

I am wanting to call a macro on sheet 1 from the change_event on sheet 6. Can this be done? I've been having a terrible time getting my workbook to sort the way I want so I've decided to go at it differently and I think if I can call my macro from sheet 6's change_event it will work.

Thanks,


_________________
Soon I hope to be answering alot of these questions instead of asking them.

viper

[ This Message was edited by: viper on 2002-03-18 15:58 ]
viper is offline   Reply With Quote
Old Mar 18th, 2002, 02:27 PM   #2
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

What do you want to do exactly?
Al Chara is offline   Reply With Quote
Old Mar 18th, 2002, 04:56 PM   #3
viper
Board Regular
 
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
Default

On sheet 6 in columns A and B I enter names of employees and in column C I enter their salary.

On Sheet 1 columns A and B the names are pulled from sheet 6 and the same with salary. Then on sheet 1 in columns D:J I enter the hours they work each day.

What I'm trying to accomplish is when I need to hire or terminate an employee I can add or remove a name from sheet 6 and still keep it alphabetized.

I have the code to alphabetize the names on sheet 6 and this works great, I can add a name at the bottom of my list and when I hit enter the macro actomatically alphabetizes the names.
My problem however, is that when these names are alphabetized on sheet 6 (which in turn keeps them alphabetized on all sheets) if I add a name or remove a name in the middle of a week and the names are alphabetized the hours I have for each person on sheet 1 (D:J) doesn't stay with name.

So, I figure I will just use sheet 6 as employee data only(names and salary) and alphabetize sheet one, that way everything associated with columns A:C will stay with A:C and not columns A:C alphabetize but columns D:J stay.

So what I'd like to do is when I add or remove a name on sheet 6 call my macro to alphabetize sheet 1, sheet 2, sheet 3, sheet 4, and sheet 5.

I hope I explained it okay, it's really hard to explain what I want to do with out you looking at my setup.

Thanks,

__________________
I appreciate the help from everyone at Mr. Excel.

viper
viper is offline   Reply With Quote
Old Mar 18th, 2002, 05:03 PM   #4
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

In answer to your original question, as long as your macro isn't defined as a private sub, you can call it from wherever you like.
Mudface is offline   Reply With Quote
Old Mar 18th, 2002, 06:07 PM   #5
viper
Board Regular
 
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
Default

Right,

But what I'm wanting to do is call the macro to alphabetize sheet 1 through sheet 5 when cells on sheet 6 change values.

I'm not sure how to do this?
viper is offline   Reply With Quote
Old Mar 18th, 2002, 06:17 PM   #6
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

Right click on worksheet 6, click view code. Paste:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1:b1000")) Is Nothing Then
application.run("Viper's Macro Name")
end if
end sub

You may want to change your target cells. Me thinks you can call private subs with this procedure.

Hope this helps.

_________________
Cheers, NateO

[ This Message was edited by: NateO on 2002-03-18 17:35 ]
NateO is offline   Reply With Quote
Old Mar 18th, 2002, 07:17 PM   #7
viper
Board Regular
 
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
Default

Okay, new code works great. Can a formula in a cell change the way it sorts? Everything works fine but the sorting. I can call the macro, it will activate on the cells changing but the sorting does not stay the same on each worksheet.

On sheet 6 the sorting works as I want. Top to bottom(all empty cells at the bottom) but on the other worksheets the empty cells are at the top then the names alphabetized. Example: sheet 6 range A5:C10 only two names in this range. Both names alphabetized in A5,A6 then empty cells, on the other sheets same range but empty cells at top in cells A5,A6,A7,A8 then the names in A9,A10. The only difference is the range on sheets 1-5 contain an ='sheet6'!A6 in each cell. Can this effect the sorting?
__________________
I appreciate the help from everyone at Mr. Excel.

viper
viper 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 04:33 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