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 Feb 18th, 2002, 08:24 AM   #1
Guest
 
Posts: n/a
Default

I was wondering if anyone knows how to tell excel to look at a column and insert a row in between each different value
  Reply With Quote
Old Feb 18th, 2002, 09:08 AM   #2
Juan Pablo González
MrExcel MVP
 
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
Default

Can you be a little more specific in what you want/expect ? along with some source data ?
__________________
Regards,

Juan Pablo González
http://www.juanpg.com
Juan Pablo González is offline   Reply With Quote
Old Feb 18th, 2002, 09:23 AM   #3
Paul B
Board Regular
 
Join Date: Feb 2002
Location: Georgia USA
Posts: 544
Default

If I understand right, this Marco Written by Barrie Davidson will do what you want
Sub Insert_row()

' Written by Barrie Davidson

Dim Number_of_rows As Long

Dim Rowinsert As Integer

Number_of_rows = Range("A65536").End(xlUp).Row

Ans = InputBox("How many rows do you want to insert ?", "Rows", 1)

If IsNumeric(Ans) Then

Rowinsert = CInt(Ans)

Else

MsgBox "Invalid number entered", vbCritical, "Error"

Exit Sub

End If

Range("A2").Select

Do Until Selection.Row = Number_of_rows + 1

If Selection.Value <> Selection.Offset(-1, 0).Value Then

Selection.EntireRow.Resize(Rowinsert).Insert

Number_of_rows = Number_of_rows + Rowinsert

Selection.Offset(Rowinsert + 1, 0).Select

Else

Selection.Offset(1, 0).Select

End If

Loop

End Sub

Paul B is offline   Reply With Quote
Old Feb 18th, 2002, 11:58 AM   #4
Guest
 
Posts: n/a
Default

Thanks, Paul B it worked great and will save me a lot of time. Again, THANKS!!!!!
  Reply With Quote
Old Feb 18th, 2002, 07:57 PM   #5
Q45
New Member
 
Join Date: Feb 2002
Posts: 32
Default

That is great. How would I tweak this to only insert one row at a time beneath a highlighted cell?

Q45 is offline   Reply With Quote
Old Feb 19th, 2002, 12:59 AM   #6
Tikas A. Planck
 
Join Date: Feb 2002
Posts: 47
Default

Select a cell.
Turn on the macro recorder.
Goto Inset>Rows.
Turn off the macro recorder.

You now have your macro.
Tikas A. Planck is offline   Reply With Quote
Old Mar 25th, 2003, 11:46 AM   #7
msohail
Board Regular
 
Join Date: Oct 2002
Posts: 120
Default Automatically Insert an X number of rows

Hi,
Further to the solution given below, I have pasted the VDB code but not getting the desired results. I want to insert 2 blank after each row with data in it. e.g

aa
a
a

should look like:
aa


a


a

after the auto insert of rows. Can anyone help pls? :o
msohail is offline   Reply With Quote
Old Mar 25th, 2003, 11:48 AM   #8
Juan Pablo González
MrExcel MVP
 
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
Default

Try using something like this, and then sorting by column B

******** ******************** ************************************************************************>
Microsoft Excel - Libro2___Running: xl2000 : OS = Windows ME
(F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)bout
=

A
B
C
D
1
aa1**
2
a2**
3
a3**
4
*1**
5
*2**
6
*3**
7
*1**
8
*2**
9
*3**
Hoja1*

[HtmlMaker 2.20] To see the formula in the cells just click on the cells hyperlink or click the Name box
PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.
__________________
Regards,

Juan Pablo González
http://www.juanpg.com
Juan Pablo González is offline   Reply With Quote
Old Mar 25th, 2003, 11:52 AM   #9
msohail
Board Regular
 
Join Date: Oct 2002
Posts: 120
Default

ThanQ Juan, simple but effective, it works.
msohail 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:12 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