Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Andre Kruger
 
Posts: n/a
Default Looping a selection of rows


Hi

I need to create a loop which will select 4 rows copy and paste it to a new
sheet. then go to the Next 4 rows and copy them to a new sheet. I need this
to happen untill the row is blank (empty).

Any idea how to do this loop?


  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Looping a selection of rows

I used column A to find that last used row.

Option Explicit
Sub testme()

Dim CurWks As Worksheet
Dim NewWks As Worksheet
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim myStep As Long

Set CurWks = Worksheets("sheet1")

myStep = 4

With CurWks

FirstRow = 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = FirstRow To LastRow Step myStep
Set NewWks = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
.Rows(iRow).Resize(myStep).Copy _
Destination:=NewWks.Range("a1")
Next iRow

End With

End Sub

Andre Kruger wrote:

Hi

I need to create a loop which will select 4 rows copy and paste it to a new
sheet. then go to the Next 4 rows and copy them to a new sheet. I need this
to happen untill the row is blank (empty).

Any idea how to do this loop?


--

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
auto expand rows [email protected] Excel Worksheet Functions 3 December 14th 05 07:45 AM
Rows & Columns in Excel seadragon69 Excel Worksheet Functions 2 December 7th 05 05:54 PM
Automatically inserting rows ausdiver99 Excel Worksheet Functions 1 June 2nd 05 02:15 PM
Hiding Rows if the linked rows are blank KG Excel Discussion (Misc queries) 9 May 18th 05 02:32 AM
flexible paste rows function that inserts the right number of rows marika1981 Excel Discussion (Misc queries) 1 February 18th 05 02:40 AM


All times are GMT +1. The time now is 09:39 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"