How do I add rows at fixed intervals-add values after every 5 Rows

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My data is in a single Column from Row 2 to 6000. I need to add the values
after every 5 Rows.
 
Hi,

You can try writing this macro. Let me know if it helps:

Sub addRows()
Dim intcount As Integer
For intcount = 7 To 7200 Step 6 ' The first formula will appear in row 7
and there will be ~1200 such formula cells. So total is 7200
ThisWorkbook.Worksheets("Sheet1").Range("A" & intcount).Select
Selection.Insert Shift:=xlDown
Selection.Formula = "=Sum(A" & intcount - 1 & ":A" & intcount - 5 &
")"
Selection.Font.Bold = True ' To distinguish the totals row in
bold
Selection.Font.ColorIndex = 3 ' To distinguish the totals row in
Red
Next intcount
End Sub
 
I would add another column (say A) and put this in A2:

=INT((ROW()-2)/5)
And drag down.

Then I could select my range and do
Data|Subtotals
and create a subtotal based on that column.
 
You are too much! More blessings for you.

Dave Peterson said:
I would add another column (say A) and put this in A2:

=INT((ROW()-2)/5)
And drag down.

Then I could select my range and do
Data|Subtotals
and create a subtotal based on that column.
 

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

Back
Top