Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default insert 3 rows between data

I need a loop statement to insert 3 rows between each row of data in the
active range. For example:

1
2
3

I need 3 rows inserted between 1 and 2, 3 rows inserted between 2 and 3.
Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default insert 3 rows between data

hi
is 1,2,3 your data and is it in column A? if do this would work ....
Sub addrows()
Dim c As Long
Dim r As Range
c = Cells(Rows.Count, "a").End(xlUp).Row
Set r = Range("A2")
For i = 1 To c - 1
r.EntireRow.Insert shift:=xlDown
r.EntireRow.Insert shift:=xlDown
r.EntireRow.Insert shift:=xlDown
Set r = r.Offset(1, 0)
r.Select
Next i
End Sub

if not, post back with more info.

Regards
FSt1

"timdavis100" wrote:

I need a loop statement to insert 3 rows between each row of data in the
active range. For example:

1
2
3

I need 3 rows inserted between 1 and 2, 3 rows inserted between 2 and 3.
Thanks in advance!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default insert 3 rows between data

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim HowManyRows As Long

Set wks = Worksheets("Sheet1")

HowManyRows = 3

With wks
FirstRow = 2
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = LastRow To FirstRow Step -1
.Rows(iRow).Resize(HowManyRows).Insert
Next iRow
End With
End Sub


timdavis100 wrote:

I need a loop statement to insert 3 rows between each row of data in the
active range. For example:

1
2
3

I need 3 rows inserted between 1 and 2, 3 rows inserted between 2 and 3.
Thanks in advance!


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default insert 3 rows between data

Ps. I wasn't sure what active range meant, so I looked at column A to find the
last used cell in that column.

Then I used that to determine the range that got the inserted rows.

timdavis100 wrote:

I need a loop statement to insert 3 rows between each row of data in the
active range. For example:

1
2
3

I need 3 rows inserted between 1 and 2, 3 rows inserted between 2 and 3.
Thanks in advance!


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to insert rows inbetween rows of data ? Azeem Excel Worksheet Functions 1 October 27th 09 05:03 AM
How to insert rows after each row of data (800 rows)? Jess Excel Discussion (Misc queries) 11 February 5th 09 04:20 PM
How do i insert blank rows between data that is thousands of rows paul.eatwell Excel Discussion (Misc queries) 5 April 14th 08 10:49 PM
Insert new rows based on Data in other rows mg_sv_r Excel Worksheet Functions 5 November 21st 07 01:51 PM
How to insert rows after each row of data (800 rows)? Toppers Excel Discussion (Misc queries) 0 March 23rd 06 08:49 PM


All times are GMT +1. The time now is 10:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"