Results 1 to 3 of 3

Copy only a few sheets from workbook

Threaded View

  1. #1
    Registered User
    Join Date
    05-31-2007
    Posts
    24

    Copy only a few sheets from workbook

    Greetings

    I have 16 Sheets in my workbook, I only want to copy 12 of them to a new workbook.

    I am creating new workbooks based on the code below but its coping all 16 sheets.

    the 12 sheets are named Jan through Dec

    Sub copy()
    
    Dim i As Integer
    'Dim j As Integer
    
    Dim employeeName As String, path As String, year As String
    
    If MsgBox("This will save files in assigned folder. Continue?" _
        , vbOKCancel, "Prompt") = vbCancel Then Exit Sub
            
    year = Range("A1").Value
    path = Range("A2").Value
    
    Application.ScreenUpdating = False
    
    For i = 1 To 27
    
    Application.StatusBar = "Progress..: " & i & "/" & 8
    
    employeeName = Cells(i + 2, 1)
    
    Application.DisplayAlerts = False
    If Dir(path & year, vbDirectory) = "" Then MkDir (path & year)
    
    ActiveWorkbook.SaveAs Filename:=path & year & "\" & employeeName & ".xls"
    
    Next
    
    ActiveWorkbook.SaveAs Filename:=path & "SupervisorMasterControl.xls"
    
    Application.DisplayAlerts = True
    Application.StatusBar = "Updating links..."
    
    
    Application.StatusBar = False      'return control to Excel
    Application.ScreenUpdating = True
    
    End Sub
    I have 27 employees identified on Sheet1,A3:A30

    and this creates 27 new workbooks for them including the 4 extra sheets I dont want/need them to see.

    Would it be easier to create a second "Employee.xls" workbook and have it contain ONLY the 12 sheets? if so, how would I alter this code to allow for that?

    I perfer to keep only a single workbook master but either way will work.

    Any clues?
    Last edited by Aurbo99; 06-01-2007 at 12:27 PM.

Thread Information

Users Browsing this Thread

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

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