View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dallman Ross Dallman Ross is offline
external usenet poster
 
Posts: 390
Default Create loop to insert two rows after every row of data

In . com,
spake thusly:

My Data starts at A8:C500 i have a count to find exact number of
lines.

myCount = Selection.Rows.Count

this works fine.

Now i need to the insert 2 blank lines under the first line and then
merge and center Column A and then do the same for B and C, i can do
this once but i require to repeat this for the amount of the myCount.


Maybe this will help with part of your requirement. This inserts
lines after each row of the data:

Dim i, rgTop, rgBot As Long

rgTop = 4: rgBot = 20 ' plug in your own stuff here, e.g., "myCount"

For i = rgBot To rgTop + 1 Step -1
Rows(i).Insert Shift:=xlDown
Next

It runs, but it's a bit slow. Maybe someone will tell us how to
make it faster.

=dman=

====================================
Below is a sort psuedo code for it that is foresee.



Count Rows
at begining insert 2 lines
Center and merge colums A,B and C for the three lines(1 data and 2
blank)
Repeat for line two of Data(which is now at A4 instead of A2 since the
insert)
until Count of rows = 0