View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Paul B Paul B is offline
external usenet poster
 
Posts: 709
Default How to add a row

NeedsExcelHelp4, here is one way,

Sub Insert_Row_In_ColumnB()
'insert 1 rows in column B, when data changes
Dim Number_of_rows As Long
Dim Rowinsert As Integer
Application.ScreenUpdating = False
Number_of_rows = Range("B65536").End(xlUp).Row
Rowinsert = 1
Range("B2").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
Application.ScreenUpdating = True
End Sub

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"NeedsExcelHelp4"
<NeedsExcelHelp4.23y5yp_1141143018.6369@excelfor um-nospam.com wrote in
message news:NeedsExcelHelp4.23y5yp_1141143018.6369@excelf orum-nospam.com...

Hey all...

I have a simple question... hoping someone might know the answer.

I need to insert a row after every unique cell (the column is sorted)
in a specific column.

The data starts in B4 and goes down an undetermined amount of rows
(data is always being added / deleted)... all I want to do is to add a
row after every 'group' in that column B.

I've tried Loops combined with If statements with no luck...

Thanks! :)


--
NeedsExcelHelp4
------------------------------------------------------------------------
NeedsExcelHelp4's Profile:
http://www.excelforum.com/member.php...o&userid=31898
View this thread: http://www.excelforum.com/showthread...hreadid=517358