how do i count and insert rows

C

calvin

I have Names begining with the letter C (c1205, c4356, c8609) i need 6 rows
between every name, the data i import dosent always follow this rule so i
need to insert the number of missing rows and also add a 0 to the rows i
insert.
 
M

Mike H

Hi,

I don't understand the second part of the question and possibly not even the
first part but this small macro inserts 6 rows between each value in column
A. Change MC to your column

Sub Insert_Rows()
mc = "A"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
Rows(i).Resize(6).Insert
Next i
End Sub


Mike
 
S

Simon Lloyd

calvin;344314 said:
I have Names begining with the letter C (c1205, c4356, c8609) i need 6
rows
between every name, the data i import dosent always follow this rule so
i
need to insert the number of missing rows and also add a 0 to the rows
i
insert.I would need some dummy data/workbook to workout the counting missing
rows, however this code will insert 6 rows for each instance and add
zero.


Code:
--------------------
Sub Insert_6_rows_add_0()
Dim i As Long
For i = Range("A" & Rows.Count).End(xlUp).Row To 7 Step -1
Rows(i & ":" & i - 5).EntireRow.Insert
Range("A" & i & ":A" & i - 5).Value = 0
Next i
End Sub
--------------------


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
 
C

calvin

Not quite what i am looking for lets try it again
my data is as follows
Ctu25 (names)
18
15
23
24
16
18
Ctu26 (names)
22
21
20
15
17
ctu32(names)
21
24
32
32
21
13

i need to count the rows between the names if it is 6 rows do nothing if not
add the missing rows and a zero as a place holder
6 rows between every name the data sometimes give me 3 or 5
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top