#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 41
Default Splitting a File?

Is there a way to Split a File?

For example you have a file with 10,000 Rows
Can you split it into 4 dif files with 2500 each?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Splitting a File?

Sure. You could cut and paste whatever rows you want into a different worksheet
in a new workbook and save that.

Gmata wrote:

Is there a way to Split a File?

For example you have a file with 10,000 Rows
Can you split it into 4 dif files with 2500 each?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 41
Default Splitting a File?

Thanks, thats how i being doing it, but i was hoping for a quicker way thanks!

"Dave Peterson" wrote:

Sure. You could cut and paste whatever rows you want into a different worksheet
in a new workbook and save that.

Gmata wrote:

Is there a way to Split a File?

For example you have a file with 10,000 Rows
Can you split it into 4 dif files with 2500 each?


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Splitting a File?

You could use a macro to do it, but I'm not sure it would be much quicker.

But if you have to do it lots of times, it may be easier to do it that way.

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim NewWks As Worksheet
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim myStep As Long
Dim pCtr As Long

myStep = 2500

Set wks = ActiveSheet
With wks
pCtr = 0
FirstRow = 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = 1 To LastRow Step myStep
Set NewWks = Workbooks.Add(1).Worksheets(1)
.Rows(iRow).Resize(myStep).Copy _
Destination:=NewWks.Range("a1")
With NewWks.Parent 'the new workbook
pCtr = pCtr + 1
Application.DisplayAlerts = False
.SaveAs _
Filename:="C:\temp\" & Format(Date, "yyyymm") _
& "_Part" _
& Format(pCtr, "00") & ".xls", _
FileFormat:=xlWorkbookNormal
Application.DisplayAlerts = True
.Close savechanges:=False
End With
Next iRow
End With

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

I used column A to find the last used column in the worksheet. You may have to
change this--depending on your data.

And I saved to C:\temp\yyyymmdd_Part##.xls -- the folder C:\temp has to exist!

Gmata wrote:

Thanks, thats how i being doing it, but i was hoping for a quicker way thanks!

"Dave Peterson" wrote:

Sure. You could cut and paste whatever rows you want into a different worksheet
in a new workbook and save that.

Gmata wrote:

Is there a way to Split a File?

For example you have a file with 10,000 Rows
Can you split it into 4 dif files with 2500 each?


--

Dave Peterson


--

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
splitting Last Name, First Name buggles Excel Discussion (Misc queries) 4 November 15th 07 01:07 AM
Splitting a file with lookup functions into smaller parts Dave McD Excel Worksheet Functions 3 October 25th 07 12:04 AM
Splitting a text file into individual worksheets Sam Chambers[_2_] Excel Discussion (Misc queries) 7 June 8th 07 05:10 PM
Lost file I was splitting smileydb Excel Discussion (Misc queries) 1 June 7th 07 12:19 AM
Splitting a cell c Excel Worksheet Functions 1 April 12th 05 02:40 PM


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