PC Review


Reply
Thread Tools Rate Thread

Copy ranges in sets of 30 rows into separate worksheet tabs inworkbook

 
 
Financeguy
Guest
Posts: n/a
 
      12th Jul 2009
Hi All -

Im trying to copy a range (lets say A1:F1000) from a worksheet (say
Sheet1) in consecutive rows of 30 (so A1:F30, A31:F:60 and so on) to
separate worksheet tabs (Say Sheet 2, Sheet 3 and so on) in a single
workbook.
Manually copying and pasting each set of 30 rows of data within the
range is really too time consuming.
Request your help for some simple VBA code to perform this tedious
activity.

Thanks in advance.

V
 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      12th Jul 2009
Hi

Assuming destination sheets already exists, try this:

Sub CopyRange()
FirstRow = 1
LastRow = 1000
Stp = 30
FirstCol = "A"
LastCol = "F"
sh = 2
Set TargetSh = Worksheets("Sheet1")
For r = FirstRow To LastRow Step Stp
TargetSh.Range(FirstCol & r & ":" & LastCol _
& r + Stp - 1).Copy _
Destination:=Worksheets("Sheet" & sh).Range("A1")
sh = sh + 1
Next
End Sub


Hopes this helps.
....
Per

On 12 Jul., 08:31, Financeguy <velocity...@gmail.com> wrote:
> Hi All -
>
> Im trying to copy a range (lets say A1:F1000) from a worksheet (say
> Sheet1) in consecutive rows of 30 (so A1:F30, A31:F:60 and so on) to
> separate worksheet tabs (Say Sheet 2, Sheet 3 and so on) in a single
> workbook.
> Manually copying and pasting each set of 30 rows of data within the
> range is really too time consuming.
> Request your help for some simple VBA code to perform this tedious
> activity.
>
> Thanks in advance.
>
> V


 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      12th Jul 2009
Sub copyblocks()
ms = 30
sh = 2
On Error Resume Next
For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row Step ms
Cells(i, 1).Resize(ms, 6).Copy Sheets(sh).Cells(1, 1)
sh = sh + 1
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Financeguy" <(E-Mail Removed)> wrote in message
news:33c6baa7-cccc-42d4-8666-(E-Mail Removed)...
> Hi All -
>
> Im trying to copy a range (lets say A1:F1000) from a worksheet (say
> Sheet1) in consecutive rows of 30 (so A1:F30, A31:F:60 and so on) to
> separate worksheet tabs (Say Sheet 2, Sheet 3 and so on) in a single
> workbook.
> Manually copying and pasting each set of 30 rows of data within the
> range is really too time consuming.
> Request your help for some simple VBA code to perform this tedious
> activity.
>
> Thanks in advance.
>
> V


 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      12th Jul 2009
> Assuming destination sheets already exists, try this:

Or you can let your code add sheets that do not exist by placing these lines
of code immediately after the For statement...

If sh > Worksheets.Count Then
Worksheets.Add After:=Worksheets(Worksheets.Count)
End If

Of course, this assumes all sheets are named SheetX where X is the sequence
numbers 1, 2, 3, etc.

--
Rick (MVP - Excel)


"Per Jessen" <(E-Mail Removed)> wrote in message
news:ce4e6a0d-1160-45cb-acd7-(E-Mail Removed)...
> Hi
>
> Assuming destination sheets already exists, try this:
>
> Sub CopyRange()
> FirstRow = 1
> LastRow = 1000
> Stp = 30
> FirstCol = "A"
> LastCol = "F"
> sh = 2
> Set TargetSh = Worksheets("Sheet1")
> For r = FirstRow To LastRow Step Stp
> TargetSh.Range(FirstCol & r & ":" & LastCol _
> & r + Stp - 1).Copy _
> Destination:=Worksheets("Sheet" & sh).Range("A1")
> sh = sh + 1
> Next
> End Sub
>
>
> Hopes this helps.
> ...
> Per
>
> On 12 Jul., 08:31, Financeguy <velocity...@gmail.com> wrote:
>> Hi All -
>>
>> Im trying to copy a range (lets say A1:F1000) from a worksheet (say
>> Sheet1) in consecutive rows of 30 (so A1:F30, A31:F:60 and so on) to
>> separate worksheet tabs (Say Sheet 2, Sheet 3 and so on) in a single
>> workbook.
>> Manually copying and pasting each set of 30 rows of data within the
>> range is really too time consuming.
>> Request your help for some simple VBA code to perform this tedious
>> activity.
>>
>> Thanks in advance.
>>
>> V

>


 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      12th Jul 2009
Adding the immediately after the For statement will let the code add sheets
that do not exist...

If sh > Sheets.Count Then Sheets.Add After:=Sheets(Sheets.Count)

--
Rick (MVP - Excel)


"Don Guillett" <(E-Mail Removed)> wrote in message
news:O2pGI$(E-Mail Removed)...
> Sub copyblocks()
> ms = 30
> sh = 2
> On Error Resume Next
> For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row Step ms
> Cells(i, 1).Resize(ms, 6).Copy Sheets(sh).Cells(1, 1)
> sh = sh + 1
> Next i
> End Sub
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "Financeguy" <(E-Mail Removed)> wrote in message
> news:33c6baa7-cccc-42d4-8666-(E-Mail Removed)...
>> Hi All -
>>
>> Im trying to copy a range (lets say A1:F1000) from a worksheet (say
>> Sheet1) in consecutive rows of 30 (so A1:F30, A31:F:60 and so on) to
>> separate worksheet tabs (Say Sheet 2, Sheet 3 and so on) in a single
>> workbook.
>> Manually copying and pasting each set of 30 rows of data within the
>> range is really too time consuming.
>> Request your help for some simple VBA code to perform this tedious
>> activity.
>>
>> Thanks in advance.
>>
>> V

>


 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      12th Jul 2009
Rick,
Had OP said something about sheets I certainly would have included.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Rick Rothstein" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Adding the immediately after the For statement will let the code add
> sheets that do not exist...
>
> If sh > Sheets.Count Then Sheets.Add After:=Sheets(Sheets.Count)
>
> --
> Rick (MVP - Excel)
>
>
> "Don Guillett" <(E-Mail Removed)> wrote in message
> news:O2pGI$(E-Mail Removed)...
>> Sub copyblocks()
>> ms = 30
>> sh = 2
>> On Error Resume Next
>> For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row Step ms
>> Cells(i, 1).Resize(ms, 6).Copy Sheets(sh).Cells(1, 1)
>> sh = sh + 1
>> Next i
>> End Sub
>>
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> (E-Mail Removed)
>> "Financeguy" <(E-Mail Removed)> wrote in message
>> news:33c6baa7-cccc-42d4-8666-(E-Mail Removed)...
>>> Hi All -
>>>
>>> Im trying to copy a range (lets say A1:F1000) from a worksheet (say
>>> Sheet1) in consecutive rows of 30 (so A1:F30, A31:F:60 and so on) to
>>> separate worksheet tabs (Say Sheet 2, Sheet 3 and so on) in a single
>>> workbook.
>>> Manually copying and pasting each set of 30 rows of data within the
>>> range is really too time consuming.
>>> Request your help for some simple VBA code to perform this tedious
>>> activity.
>>>
>>> Thanks in advance.
>>>
>>> V

>>

>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Separating data onto separate worksheet tabs uneedpsi113 Microsoft Excel Misc 2 29th Jun 2009 04:26 PM
Copy data in multiple worksheet tabs into one worksheet Bob Microsoft Excel Programming 2 15th Feb 2008 03:01 PM
Excel Worksheet tabs saved as separate files Sabine Microsoft Excel Worksheet Functions 1 14th Apr 2004 05:26 AM
displaying worksheet tabs in two rows? dannycombs Microsoft Excel Misc 7 10th Mar 2004 12:57 PM
Copy sets of ranges MDC Microsoft Excel Programming 2 16th Oct 2003 10:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:21 AM.