Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default loop selecting data


I am trying to sort out a large piece of data.
I want the macro to copy the first 297 rows copy and paste this on a new
sheet.
I then want it to be able to loop this however skip the first 297 rows and
copy the next 297 and copy this into a new sheet.

I am new to VBA and am struggling to get this to run, any help would be
fantastic.




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default loop selecting data

Meggie,

Copying 297 rows of data from one sheet to another can be accomplished with
a command similar to the following:

Sheet1.Range("1:297").Copy Sheet2.Range("a1")

You would have to replace the sheet objects Sheet1 & Sheet2 with the
appropriate object names. I'm not certain what you are trying to accomplish
after this though, please elaborate & I will try to assist.
--
Regards,
Eddie
http://www.HelpExcel.com


"meggie" wrote:


I am trying to sort out a large piece of data.
I want the macro to copy the first 297 rows copy and paste this on a new
sheet.
I then want it to be able to loop this however skip the first 297 rows and
copy the next 297 and copy this into a new sheet.

I am new to VBA and am struggling to get this to run, any help would be
fantastic.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default loop selecting data

Do you mean to different sheets...If then replace Sheet2 with a variable..

Sub mac()
With ActiveWorkbook
For intLoop = 1 To 5
..Sheets("Sheet1").Range((intLoop - 1) * 297 + 1 & ":" & (intLoop *
297)).Copy _
Sheets("Sheet2").Range("a" & (intLoop - 1) * 297 + 1)
Next
End With
End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"meggie" wrote:


I am trying to sort out a large piece of data.
I want the macro to copy the first 297 rows copy and paste this on a new
sheet.
I then want it to be able to loop this however skip the first 297 rows and
copy the next 297 and copy this into a new sheet.

I am new to VBA and am struggling to get this to run, any help would be
fantastic.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default loop selecting data

Try the below macro with data in Sheet1.....should copy 297 records to new
sheets until end of data

Sub CopySplitSheet()
Dim intLoop As Integer
Dim lngLastRow As Long
lngLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
With ActiveWorkbook
Do
intLoop = intLoop + 1
..Sheets("Sheet1").Range((intLoop - 1) * 2 + 1 & ":" & (intLoop * 2)).Copy
Sheets.Add
..ActiveSheet.Paste
Loop Until (intLoop * 2) = lngLastRow
End With
End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"meggie" wrote:


I am trying to sort out a large piece of data.
I want the macro to copy the first 297 rows copy and paste this on a new
sheet.
I then want it to be able to loop this however skip the first 297 rows and
copy the next 297 and copy this into a new sheet.

I am new to VBA and am struggling to get this to run, any help would be
fantastic.




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
Selecting a range by using a loop lasca Excel Programming 2 October 25th 07 04:51 PM
selecting multiple ActiveCell items (possibly loop problem) jono_dude Excel Programming 2 December 19th 06 12:37 AM
selecting columns and a loop John Excel Programming 0 August 24th 05 06:59 PM
Selecting columns through a loop GreenInIowa Excel Programming 5 July 22nd 05 04:53 PM
need some help with selecting a sheet in a loop again Gary Keramidas[_2_] Excel Programming 6 July 7th 05 09:48 PM


All times are GMT +1. The time now is 11:04 AM.

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"