Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default split worksheet after empty row into separate workbooks

I use syntax to split my Master worksheet into several worksheets in the same
workbook but now I need to be able to create separate workbooks with only one
worksheet information instead of separate worksheets.

How can I modify this syntax and also to be able to name my workbooks
acording to the name I have in column 6.

I will appreciate very much your advice dear experts.

Sub SplitData()
mycount = 0
myrow = 0
Do
mycount = mycount + 1
oldrow = myrow + 1
Sheets("Master").Select
Do
myrow = myrow + 1
Loop Until Sheets("Master").Range("A" & myrow) = ""
Sheets.Add
ActiveSheet.Name = "Data" & mycount
Sheets("Master").Select
Rows(oldrow & ":" & myrow).Select
Selection.Copy
Sheets("Data" & mycount).Select
Range("A1").Select
ActiveSheet.Paste
Loop Until Sheets("Master").Range("A" & myrow + 1) = ""
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default split worksheet after empty row into separate workbooks

Hi

I assume you have the 'new' workbook name if first row of each data set in
column 6 and one empty row between each data set.

Sub SplitData2()
Dim MasterSh As Worksheet
Dim FirstCell As Range
Dim LastCell As Range
Dim NewWb As Workbook
Dim vbName as String
Application.ScreenUpdating = False

Set MasterSh = Worksheets("Master")
Set FirstCell = MasterSh.Range("A1")
Do
Set LastCell = FirstCell.End(xlDown)
wbName = FirstCell.Offset(0, 5).Value
Set NewWb = Workbooks.Add
Range(FirstCell, LastCell).EntireRow.Copy
NewWb.Worksheets(1).Range("A1")
NewWb.SaveAs Filename:=wbName
NewWb.Close
Set FirstCell = LastCell.Offset(2, 0)
Loop Until FirstCell = ""
Application.ScreenUpdating = True
End Sub

Regards,
Per

"Marylu" skrev i meddelelsen
...
I use syntax to split my Master worksheet into several worksheets in the
same
workbook but now I need to be able to create separate workbooks with only
one
worksheet information instead of separate worksheets.

How can I modify this syntax and also to be able to name my workbooks
acording to the name I have in column 6.

I will appreciate very much your advice dear experts.

Sub SplitData()
mycount = 0
myrow = 0
Do
mycount = mycount + 1
oldrow = myrow + 1
Sheets("Master").Select
Do
myrow = myrow + 1
Loop Until Sheets("Master").Range("A" & myrow) = ""
Sheets.Add
ActiveSheet.Name = "Data" & mycount
Sheets("Master").Select
Rows(oldrow & ":" & myrow).Select
Selection.Copy
Sheets("Data" & mycount).Select
Range("A1").Select
ActiveSheet.Paste
Loop Until Sheets("Master").Range("A" & myrow + 1) = ""
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default I need to separate 45K rows of data into 45 separate workbooks (1000rows per)

I am hoping that you can help me. I need to separate 45k rows of data into 45 separate workbooks (not sheets)
The data is First name, last name, phone, email, address.

I need these to be saved as CSV files. I am not at all a programmer and do not know much about VB.

Thank you!



Per Jessen wrote:

HiI assume you have the 'new' workbook name if first row of each data set
17-Oct-09

Hi

I assume you have the 'new' workbook name if first row of each data set in
column 6 and one empty row between each data set.

Sub SplitData2()
Dim MasterSh As Worksheet
Dim FirstCell As Range
Dim LastCell As Range
Dim NewWb As Workbook
Dim vbName as String
Application.ScreenUpdating = False

Set MasterSh = Worksheets("Master")
Set FirstCell = MasterSh.Range("A1")
Do
Set LastCell = FirstCell.End(xlDown)
wbName = FirstCell.Offset(0, 5).Value
Set NewWb = Workbooks.Add
Range(FirstCell, LastCell).EntireRow.Copy
NewWb.Worksheets(1).Range("A1")
NewWb.SaveAs Filename:=wbName
NewWb.Close
Set FirstCell = LastCell.Offset(2, 0)
Loop Until FirstCell = ""
Application.ScreenUpdating = True
End Sub

Regards,
Per

Previous Posts In This Thread:

On Friday, October 16, 2009 9:16 PM
Marylu wrote:

split worksheet after empty row into separate workbooks
I use syntax to split my Master worksheet into several worksheets in the same
workbook but now I need to be able to create separate workbooks with only one
worksheet information instead of separate worksheets.

How can I modify this syntax and also to be able to name my workbooks
acording to the name I have in column 6.

I will appreciate very much your advice dear experts.

Sub SplitData()
mycount = 0
myrow = 0
Do
mycount = mycount + 1
oldrow = myrow + 1
Sheets("Master").Select
Do
myrow = myrow + 1
Loop Until Sheets("Master").Range("A" & myrow) = ""
Sheets.Add
ActiveSheet.Name = "Data" & mycount
Sheets("Master").Select
Rows(oldrow & ":" & myrow).Select
Selection.Copy
Sheets("Data" & mycount).Select
Range("A1").Select
ActiveSheet.Paste
Loop Until Sheets("Master").Range("A" & myrow + 1) = ""
End Sub

On Saturday, October 17, 2009 3:15 AM
Per Jessen wrote:

HiI assume you have the 'new' workbook name if first row of each data set
Hi

I assume you have the 'new' workbook name if first row of each data set in
column 6 and one empty row between each data set.

Sub SplitData2()
Dim MasterSh As Worksheet
Dim FirstCell As Range
Dim LastCell As Range
Dim NewWb As Workbook
Dim vbName as String
Application.ScreenUpdating = False

Set MasterSh = Worksheets("Master")
Set FirstCell = MasterSh.Range("A1")
Do
Set LastCell = FirstCell.End(xlDown)
wbName = FirstCell.Offset(0, 5).Value
Set NewWb = Workbooks.Add
Range(FirstCell, LastCell).EntireRow.Copy
NewWb.Worksheets(1).Range("A1")
NewWb.SaveAs Filename:=wbName
NewWb.Close
Set FirstCell = LastCell.Offset(2, 0)
Loop Until FirstCell = ""
Application.ScreenUpdating = True
End Sub

Regards,
Per

EggHeadCafe - Software Developer Portal of Choice
..NET GDI+ - Convert BitMap To Jpeg
http://www.eggheadcafe.com/tutorials...ert-bitma.aspx
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default I need to separate 45K rows of data into 45 separate workbooks (1000 rows per)

Hi

Try this:

Sub SplitDataToCSV()
Dim MasterSh As Worksheet
Dim FirstRow As Long
Dim LastRow As Long
Dim NewWb As Workbook
Dim wbName As String
Dim counter As Long
Application.ScreenUpdating = False

Set MasterSh = Worksheets("Master")
FirstRow = 1
LastRow = MasterSh.Range("A" & Rows.Count).End(xlUp).Row
For r = FirstRow To LastRow Step 1000
counter = counter + 1
wbName = "Exported" & counter & ".csv" ' change name as required
Set NewWb = Workbooks.Add
MasterSh.Range("A" & r).Resize(1000, 1).EntireRow.Copy _
NewWb.Worksheets(1).Range("A1")

NewWb.SaveAs Filename:=wbName, _
FileFormat:=xlCSV, CreateBackup:=False
NewWb.Close
Next
Application.ScreenUpdating = True
End Sub

Regards,
Per

"Charles Simpson" skrev i meddelelsen
...
I am hoping that you can help me. I need to separate 45k rows of data into
45 separate workbooks (not sheets)
The data is First name, last name, phone, email, address.

I need these to be saved as CSV files. I am not at all a programmer and
do not know much about VB.

Thank you!



Per Jessen wrote:

HiI assume you have the 'new' workbook name if first row of each data set
17-Oct-09

Hi

I assume you have the 'new' workbook name if first row of each data set in
column 6 and one empty row between each data set.

Sub SplitData2()
Dim MasterSh As Worksheet
Dim FirstCell As Range
Dim LastCell As Range
Dim NewWb As Workbook
Dim vbName as String
Application.ScreenUpdating = False

Set MasterSh = Worksheets("Master")
Set FirstCell = MasterSh.Range("A1")
Do
Set LastCell = FirstCell.End(xlDown)
wbName = FirstCell.Offset(0, 5).Value
Set NewWb = Workbooks.Add
Range(FirstCell, LastCell).EntireRow.Copy
NewWb.Worksheets(1).Range("A1")
NewWb.SaveAs Filename:=wbName
NewWb.Close
Set FirstCell = LastCell.Offset(2, 0)
Loop Until FirstCell = ""
Application.ScreenUpdating = True
End Sub

Regards,
Per

Previous Posts In This Thread:

On Friday, October 16, 2009 9:16 PM
Marylu wrote:

split worksheet after empty row into separate workbooks
I use syntax to split my Master worksheet into several worksheets in the
same
workbook but now I need to be able to create separate workbooks with only
one
worksheet information instead of separate worksheets.

How can I modify this syntax and also to be able to name my workbooks
acording to the name I have in column 6.

I will appreciate very much your advice dear experts.

Sub SplitData()
mycount = 0
myrow = 0
Do
mycount = mycount + 1
oldrow = myrow + 1
Sheets("Master").Select
Do
myrow = myrow + 1
Loop Until Sheets("Master").Range("A" & myrow) = ""
Sheets.Add
ActiveSheet.Name = "Data" & mycount
Sheets("Master").Select
Rows(oldrow & ":" & myrow).Select
Selection.Copy
Sheets("Data" & mycount).Select
Range("A1").Select
ActiveSheet.Paste
Loop Until Sheets("Master").Range("A" & myrow + 1) = ""
End Sub

On Saturday, October 17, 2009 3:15 AM
Per Jessen wrote:

HiI assume you have the 'new' workbook name if first row of each data set
Hi

I assume you have the 'new' workbook name if first row of each data set in
column 6 and one empty row between each data set.

Sub SplitData2()
Dim MasterSh As Worksheet
Dim FirstCell As Range
Dim LastCell As Range
Dim NewWb As Workbook
Dim vbName as String
Application.ScreenUpdating = False

Set MasterSh = Worksheets("Master")
Set FirstCell = MasterSh.Range("A1")
Do
Set LastCell = FirstCell.End(xlDown)
wbName = FirstCell.Offset(0, 5).Value
Set NewWb = Workbooks.Add
Range(FirstCell, LastCell).EntireRow.Copy
NewWb.Worksheets(1).Range("A1")
NewWb.SaveAs Filename:=wbName
NewWb.Close
Set FirstCell = LastCell.Offset(2, 0)
Loop Until FirstCell = ""
Application.ScreenUpdating = True
End Sub

Regards,
Per

EggHeadCafe - Software Developer Portal of Choice
.NET GDI+ - Convert BitMap To Jpeg
http://www.eggheadcafe.com/tutorials...ert-bitma.aspx


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
How to combine data from 2 separate workbooks onto 1 worksheet Kristen Excel Worksheet Functions 2 March 17th 10 07:05 PM
TOUGH:split file into separate workbooks (single row, plus group m intoit Excel Programming 2 September 8th 09 02:11 AM
Split 9 weeks of data on a worksheet into 9 separate worksheets BeSmart Excel Programming 1 November 5th 08 12:15 AM
how do i split a cell that contains dd/mm/yy into a 3 separate cel Eva Excel Discussion (Misc queries) 2 October 2nd 07 07:35 PM
how do I get separate workbooks in separate windows John Collins Excel Discussion (Misc queries) 3 October 28th 06 12:07 AM


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