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 30th, 2002, 05:06 AM   #1
MattB
Board Regular
 
Join Date: Mar 2002
Posts: 62
Default

Is there a way without using code to insert 4 rows after each subtotal?
If code is the way forward could somebody give me a shove in the right direction please.
Cheers.
MattB is offline   Reply With Quote
Old Apr 30th, 2002, 09:06 AM   #2
Iain Lewis
Board Regular
 
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
Default

This code will do it. As I don't know where on the sheet the Subtotal is you will need to select a cell in the row beneath the Subtotal.

Sub aaa()
Range(ActiveCell, ActiveCell.Offset(3, _ 0)).Select
Selection.EntireRow.Insert
End Sub

If you'd like it explained then just give me a shout.
Iain Lewis is offline   Reply With Quote
Old Apr 30th, 2002, 09:18 AM   #3
MattB
Board Regular
 
Join Date: Mar 2002
Posts: 62
Default

Cheers Ian
The sheet is made up of hundreds of subtotals and i'd like to insert 4 rows after each of them; the first cell beneath the subtotal in this instance is A15, however i need to run similar reports daily with different info. So ideally i'd like a macro that can insert the rows after the subtotals for each report that i run.
Matt
MattB is offline   Reply With Quote
Old Apr 30th, 2002, 09:35 AM   #4
Iain Lewis
Board Regular
 
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
Default

Are you using the Subtotal wizard to apply the subtotal ?
Iain Lewis is offline   Reply With Quote
Old Apr 30th, 2002, 10:05 AM   #5
MattB
Board Regular
 
Join Date: Mar 2002
Posts: 62
Default

Sorry for the delay, i just use Data>Subtotals.
MattB is offline   Reply With Quote
Old May 1st, 2002, 01:47 AM   #6
MattB
Board Regular
 
Join Date: Mar 2002
Posts: 62
Default

Sorry to be a pain but i'm really struggling with this task!, any suggestions before I spend the next 3 hours inserting rows?!!
MattB is offline   Reply With Quote
Old May 1st, 2002, 01:58 AM   #7
Iain Lewis
Board Regular
 
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
Default

Here you go. This code looks for "x Total" in column A ( just change a65536 to which ever column you need ).

Sub aaa()
Range("a65536").End(xlUp).Offset(-2, 0).Select
Do Until ActiveCell.Row = 1
If Right(ActiveCell, 5) = "Total" Then
Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(3, 0)).EntireRow.Insert
ActiveCell.Offset(-1, 0).Select
Else
ActiveCell.Offset(-1, 0).Select
End If
Loop
End Sub
Iain Lewis is offline   Reply With Quote
Old May 1st, 2002, 01:59 AM   #8
MattB
Board Regular
 
Join Date: Mar 2002
Posts: 62
Default

Good man!
I'll give it a shot
MattB is offline   Reply With Quote
Old May 1st, 2002, 02:38 AM   #9
MattB
Board Regular
 
Join Date: Mar 2002
Posts: 62
Default

Excellent!, how much do I owe you?!
I now need something slightly more advanced.
Each of the subtotals gives me a figure in column H, in the cell to the right of that I need to i need to multiply this total by 1.056, is it possible to incorporate this into the code so that it calculates it for every subtotal in the sheet.
What would be even better would be to have 2 blank cells to the right of the calculation (these have to be added manually) and a total in the next cell to the right which adds the 4 figures together.
Or am i pushing my luck!?
MattB is offline   Reply With Quote
Old May 1st, 2002, 04:13 AM   #10
MattB
Board Regular
 
Join Date: Mar 2002
Posts: 62
Default

OK, i've managed that but I do need 1 more thing!
The data that i said needs to be added manually in the cell next to the 0.056 calculation may not need to be after all.
The data within the subtotal is a total of all of the in-house material for that particular part code. We apply a certain % to this, hence the 0.056 calculation.
However, there are also codes within the subtotal that are outsourced - I have highlighted these by conditional formatting (they return a code in the L column which differentiates them from the in-house material).
The outsourced codes have a different % applied, so the problems are:
Can a macro be written to enable the subtotal to subtract all of the costs that are subcontracted?, and
Can the subtotal cost be added into the necessary cell with a % applied to it?
This is probably clear as mud!
MattB 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 03:57 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