View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default TOUGH:split file into separate workbooks (single row, plus group m

something simple like this maybe?

Sub NewBooks()
Dim thisrow As Long
Dim lastrow As Long
Dim wb As Workbook
Dim wbws As Worksheet

lastrow = Range("A" & Cells.Count).End(xlUp).Row

With ActiveSheet
For thisrow = 1 To lastrow - 1
Set wb = Workbooks.Add()
Set wbws = wb.ActiveSheet
.Rows(thisrow).Copy
wbws.Rows(1).PasteSpecial xlPasteAll
.Rows(lastrow).Copy
wbws.Rows(2).PasteSpecial xlPasteAll
wb.SaveAs thisrow
wb.Close False
Next
End With
End Sub

"intoit" wrote:

Hi,

I would like to split the data within a worksheet into separate workbooks,
whereby a unique workbook is created for each row that has data. I'm using
the vba code on this site: http://www.rondebruin.nl/copy5_3.htm which is
very useful, however, I need the code to not only copy the information for
each unique row into a unique workbook, but also copy the column means
associated with the group (which is reported in the last used row of the
worksheet). The size of the group will vary from time to time, so the code
couldn't specify within which row the group means will be reported.

Any ideas here? Thanks.