Thread: Writing a macro
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default Writing a macro

One way

Sub addrowsandfill()
For i = Cells(Rows.Count, "a").End(xlUp).Row To 12 Step -1
x = Cells(i, 1)
If Cells(i, 1) < Cells(i - 1, 1) Then
Cells(i, 1).Resize(4).EntireRow.Insert
Cells(i, 1).Resize(5).Value = x
End If
Next
End Sub


--
Don Guillett
SalesAid Software

"Roxio" wrote in
message ...

I need to write a macro that will allow me to add any number of rows (as
desired) BETWEEN each of the existing values in column A. Now when this
is done, it must at the same time populate these new rows with with cell
values above the inserted rows.

So if A1 = Apples... and I add 5 rows,only the cells inserted in col A
below A1 should take the value "Apples" until the next value Pears.
Then the next 5 cells below Pears should have "Pears".

Hope this is explained clearly.

Thanx
Roxio


--
Roxio
------------------------------------------------------------------------
Roxio's Profile:

http://www.excelforum.com/member.php...o&userid=28366
View this thread: http://www.excelforum.com/showthread...hreadid=479478