+ Reply to Thread
Results 1 to 4 of 4

Split a workbook into multiple workbooks

Hybrid View

  1. #1
    Registered User
    Join Date
    10-16-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    20

    Split a workbook into multiple workbooks

    Hi! I'd like to ask for help with this:

    I need to split a workbook into different workbooks.
    1. Splitting will be based on SheetA!Column E, that is ABB-C7-D1 will have its own workbook, ABBBB-C11 will have another and so on. The values in Column E will also be the filename for its corresponding workbook. I admit several codes to execute this are already available but I couldn't make it applicable (largely because of my VBA ignorance) with my file.
    2. SheetA contains data validation list which depend on SheetB (which by the way, I intend to hide). So, for all the formula in SheetA to work, SheetB must be copied in every file simultaneosly with the splitting process.
    3. I hope security settings and the current format (e.g. width of the columns) of the primary file could also be same across all the resulting files.

    Thank you for taking time to read my post!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Split a workbook into multiple workbooks

    Maybe:

    Sub stewfeed()
    Dim rcell As Range
    Dim wbk As Workbook
    Dim ws As Worksheet
    Dim ws2 As Worksheet
    Dim ws3 As Worksheet
    
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    
    Set wbk = ActiveWorkbook
    Set ws = ActiveSheet
    
    For Each rcell In ws.Range("E7:E" & ActiveSheet.UsedRange.Rows.Count)
    
        If rcell.Value <> "" Then
        
            ws.Range(rcell, rcell.Offset(4)).EntireRow.Copy
        
            Workbooks.Add
                ActiveWorkbook.SaveAs Filename:="D:\Common\data\YOUR FILE AND PATH\" & rcell.Value & ".xls", _
                FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
                ReadOnlyRecommended:=False, CreateBackup:=False
                
            Set ws2 = Sheets("Sheet1")
            Set ws3 = Sheets("Sheet2")
            ws3.Name = "B"
            ws3.Cells.Value = wbk.Sheets("B").Cells.Value
                
            ws.Range(rcell, rcell.Offset(3)).EntireRow.Copy ws2.Range("A7")
            ws.Range("A6").EntireRow.Copy ws2.Range("A6")
        End If
        
    Next rcell
    
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    
    End Sub

  3. #3
    Registered User
    Join Date
    10-16-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Split a workbook into multiple workbooks

    Hi John! Thank you for your reply. By the way, I get "run-time error '7': Out of Memory"..

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Split a workbook into multiple workbooks

    Stewfeed. I don't know what would cause the Out of Memory on your computer. The file I tested the macro on worked for me.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1