Split Another Workbook sheets into multiple workbooks

Oprichnick

Board Regular
Joined
May 30, 2013
Messages
69
Hello,
I built this piece of code which is intended to rename each worksheet in XYZ Workbook and split them into new workbooks.

Indeed it is created a new workbook for each tab. However each of them is a full copy of the source workbook and not just of the sheet.

What I'm missing here?

Code:
 Sub Splittingv2()

    Dim wks As Worksheet
     
    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False


    End With


    With Workbooks("XYZ.xls")
        For Each wks In .sheets
            With wks
                If .Range("E16").Value <> "" Then .Name = Left(.Range("E16").Value, 3)
            End With
        Next wks
    End With
    
    
    With Workbooks("XYZ.xls")
        For Each wks In Workbooks("DLQ.xls").Worksheets
            With wks
               .SaveAs Filename:="C:\Path\" & wks.Name & ".xls"
            
            End With
        Next wks
    End With


    MsgBox ("The Splitting is Done")




End Sub

Thanks,
Oprichnick
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top