![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
I was wondering if anyone knows how to tell excel to look at a column and insert a row in between each different value
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
Can you be a little more specific in what you want/expect ? along with some source data ?
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Georgia USA
Posts: 544
|
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 |
|
|
|
|
|
#4 |
|
Guest
Posts: n/a
|
Thanks, Paul B it worked great and will save me a lot of time. Again, THANKS!!!!!
|
|
|
|
#5 |
|
New Member
Join Date: Feb 2002
Posts: 32
|
That is great. How would I tweak this to only insert one row at a time beneath a highlighted cell?
|
|
|
|
|
|
#6 |
|
Join Date: Feb 2002
Posts: 47
|
Select a cell.
Turn on the macro recorder. Goto Inset>Rows. Turn off the macro recorder. You now have your macro. |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Oct 2002
Posts: 120
|
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 |
|
|
|
|
|
#8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
Try using something like this, and then sorting by column B
******** ******************** ************************************************************************>
[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. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
#9 |
|
Board Regular
Join Date: Oct 2002
Posts: 120
|
ThanQ Juan, simple but effective, it works.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|