Copy Cells To Another XLS

  • Thread starter Thread starter Steve Kennedy
  • Start date Start date
S

Steve Kennedy

I've been a programmer for 10 years now. This simple thing is kicking
my butt. Any help would be appreciated.

I have a simple Excel file. It is broken up into "chunks", meaning
that every 50 rows is a "chunk". I would like to copy all the data in
each of the 50 rows to a seperate new Excel document. Each 50 rows
would be in its own file. Can someone point me in the right direction?

I would be willing to look at Excel macro code, or stand-alone
application code. Anything.

Thanks,
- Steve
 
Something like this would propably work. If the original Sheet is called
Data so this code would look for an empty cell in column A to stop the
routine.

Sub SplitDataToNewSheets()
Rw = 1
Sheets("Data").Select
Do Until Cells(Rw, 1).Value = ""
Rows(Rw & ":" & Rw + 49).Select
Selection.Copy
Sheets.Add
Rows("1:1").Select
ActiveSheet.Paste
Rw = Rw + 50
Sheets("Data").Select
Loop
End Sub

Regrds, Mika Oukka
 
The previous version one did it to new sheets. This one would distribute to
files.

-Mika

Sub CopyToNewFiles()
Rw = 1
Sheets("Data").Select
Do Until Cells(Rw, 1).Value = ""
Rows(Rw & ":" & Rw + 49).Select
Selection.Copy
Workbooks.Add
Rows("1:1").Select
ActiveSheet.Paste
ActiveWorkbook.SaveAs Filename:="C:\temp\RwsFrom" & Rw & ".xls"
ActiveWorkbook.Close
Rw = Rw + 50
Sheets("Data").Select
Loop
End Sub
 

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