Thread: add rows
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
JMay JMay is offline
external usenet poster
 
Posts: 468
Default add rows

Can't be done with a function -- must be done with code. Paste the below
into a standard module of your workbook. Below assumes that Column A is the
column that will insert a new row between change.

Be sure that you first have sorted your data on Column A is this example
first.


Sub InsertRow_A_Chg()
Dim Lrow As Long, vcurrent As String, i As Long
'// find last used cell in Column A
Lrow = Cells(Rows.Count, "A").End(xlUp).Row
'// get the value of that cell in Column A (column 1)
vcurrent = Cells(Lrow, 1).Value
'// rows are inserted by looping from bottom up
For i = Lrow To 2 Step -1
If Cells(i, 1).Value < vcurrent Then
vcurrent = Cells(i, 1).Value
Rows(i + 1).Resize(2).Insert 'Rows(i + 1).Insert to only Insert One
Blank Row
End If
Next i
End Sub

"REGENT" wrote:

What function can I use to add a row to a large spreadsheet at each change in
a value of a specified column

Desperate - the manual process is overwhelming.
--
REGENT