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 8th, 2002, 07:25 AM   #1
alexb
New Member
 
Join Date: Mar 2002
Posts: 17
Default

I have two macro's that I have written and they work. Once macro 1 has finished i want macro two to start. Is this possilbe?
alexb is offline   Reply With Quote
Old Mar 8th, 2002, 07:29 AM   #2
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

Before the final 'End Sub' in your first macro add the line

Call Macro2 ' change to whatever your second Macro is called

You can just use Macro2 without the Call, if you like, I tend to leave it in as it shows up what you're doing a bit more readily.
Mudface is offline   Reply With Quote
Old Mar 8th, 2002, 07:38 AM   #3
Guest
 
Posts: n/a
Default

That is fine (and works) but I have written this in the This Workbook part of VBA and can't name the macro - would typing
Call Thisworkbook do the trick?
  Reply With Quote
Old Mar 8th, 2002, 07:42 AM   #4
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

Don't think so. I presume you've put the macro code into the Workbook_Open() sub so try the following:-

Private Sub Workbook_Open()

Call Macro1
Call Macro2

End Sub

Insert a module and cut and paste your two macro's into it. You'll probably need to name your first macro, just put: -

Public Sub Macro1()

before your code and make sure there's an End Sub after it. HTH.
Mudface is offline   Reply With Quote
Old Mar 8th, 2002, 08:04 AM   #5
Guest
 
Posts: n/a
Default

Doesn't want to do it as I need my macro to run first. I need the work book_open() to run at the end of Macro1
  Reply With Quote
Old Mar 8th, 2002, 08:10 AM   #6
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

Could you post your code, please, as I don't quite get what you're driving at. The workbook open routine runs due to the workbook open event and therefore, by definition, should run before any other macros and shouldn't need to be called.
Mudface is offline   Reply With Quote
Old Mar 8th, 2002, 08:54 AM   #7
Guest
 
Posts: n/a
Default

Here we go then:
This is my first macro:
Sub emailnew2()
'
' emailnew2 Macro
' Macro recorded 3/7/2002 by Base-Displays
'

'
Sheets("sheet11").Select
Range("E22:E79").Select
Selection.ClearContents
Sheets("Sheet 1").Select
Range("E11:E68").Select
Selection.Copy
Sheets("sheet11").Select
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=85
Range("E95:E118").Select
Application.CutCopyMode = False
Selection.ClearContents
Sheets("Sheet 1").Select
ActiveWindow.SmallScroll Down:=73
Range("E82:E105").Select
Selection.Copy
Sheets("sheet11").Select
ActiveSheet.Paste
ActiveWindow.ScrollRow = 1
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Range("A1").Select
ActiveWindow.Zoom = 75
Application.CutCopyMode = False
With ActiveWindow
.DisplayHeadings = False
.DisplayWorkbookTabs = False
End With
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

When the new sheet is opened I want to display my special offer Stop press window (this is a price I can send to customers)that will pop up before they see the whole work book - does this all make sense?
  Reply With Quote
Old Mar 8th, 2002, 09:11 AM   #8
Guest
 
Posts: n/a
Default

Think so . I'm presuming the message you want to show is in the workbook_open sub of the initial workbook, yes?

If so, go to the module in your post above and click on insert- procedure and name the procedure Macro 2, for example.

Go to your workbook_open sub and cut and paste the code in there (minus the workbook_open() and end sub bits) into the new Macro2 procedure. Add Call Macro2 to your Workbook_Open sub and add the same to your emailnew2 sub at the end.

Your code should now look like: -

Private Sub Workbook_Open()

Call Macro2

End Sub

And in the module: -

Sub emailnew2()
'
' emailnew2 Macro
' Macro recorded 3/7/2002 by Base-Displays
'

'
' .... all your code as above

Call Macro2

End Sub


Public Sub Macro2()

'your code

End Sub

Note that the code you have in Macro2 will not be propagated to the new workbook, however...
  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:34 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