+ Reply to Thread
Results 1 to 2 of 2

Macro Help (Save copy of tab to new excel file)

  1. #1
    Registered User
    Join Date
    01-27-2013
    Location
    NEw York
    MS-Off Ver
    Excel 2003
    Posts
    1

    Macro Help (Save copy of tab to new excel file)

    Hey all, i heard this was a well respected forum with good feedback. I need a little guidance...
    I have a master file 'Copy and Save.xlsm'. It contains 3 tabs: FR, GM, and CH.

    I want to save a copy of each tab to a new Excel file and name the file as Tab name - Master file name, e.g. FR - Copy and Save. xls. The master file is a Macro enabled Excel 2003 format and The new file need to be plain Excel 2003-2007 format rather than a Macro enabled format..(It should be ok to change the master file to Macro enabled format but the new files have to be Excel 2003 format...)

    My Macro is able to create a new workbook, save and name it but can't move on to the next tab...


    Sub copy_save()
    '
    ' Move and make a copy of each tab from the master file and save as a new workbook. Name it tab name - master file name
    '
    '
    ActiveSheet.Select
    pName = ActiveWorkbook.Path ' the path of the currently active file, the master file
    wbName = ActiveWorkbook.Name ' the file name of the currently active master file
    shtName = ActiveSheet.Name ' the name of the currently selected worksheet, the master file

    For i = 1 To Worksheets.Count

    ActiveSheet.Select
    ActiveSheet.Copy
    Tabname = pName & "\" & shtName & " - " & wbName 'Name the new workbook as: Tab name - master file name

    Dim Newshtname As String
    Newshtname = Tabname

    ActiveWorkbook.SaveAs Filename:= _
    Newshtname, FileFormat:= _
    xlOpenXMLWorkbook, CreateBackup:=False


    Sheet(shtName).Activate ' want to Return to master file and move and save the next tab. This doesn't work however.

    Range("A1").Select

    ActiveSheet.Next.Select 'move to next tab

    Next i

    End

    End Sub

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro Help (Save copy of tab to new excel file)

    Try this...

    Please Login or Register  to view this content.

+ Reply to Thread

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