+ Reply to Thread
Results 1 to 10 of 10

VBA Code To Copy Worksheet Tab To A New WorkSheet

  1. #1
    Registered User
    Join Date
    07-11-2012
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    91

    VBA Code To Copy Worksheet Tab To A New WorkSheet

    Hi All,

    Do you have a vba code that would copy one worksheet tab to a new worksheet and save the new worksheet to a folder? Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: VBA Code To Copy Worksheet Tab To A New WorkSheet

    Hi.

    Do you mean copy to a new workbook?

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Code To Copy Worksheet Tab To A New WorkSheet

    Do you mean save the worksheet to a new workbook and save it to a folder?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Registered User
    Join Date
    07-11-2012
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    91

    Re: VBA Code To Copy Worksheet Tab To A New WorkSheet

    Yes. Copy 1 tab of the current workbook and paste it to a new workbook. The new workbook should contain only 1 tab and the tab's cells are copy and pasted as values. Then this new workbook should be saved in a folder.

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Code To Copy Worksheet Tab To A New WorkSheet

    Copy this code into your current workbook -
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose Tools | Macro | Macros
    Select a macro in the list, and click the Run button

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Code To Copy Worksheet Tab To A New WorkSheet

    Copy this code into your current workbook -
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose Tools | Macro | Macros
    Select a macro in the list, and click the Run button

  7. #7
    Registered User
    Join Date
    07-11-2012
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    91

    Re: VBA Code To Copy Worksheet Tab To A New WorkSheet

    is there a way to save it looking up to an excel file in that worksheet as the folder changes according to date?

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Code To Copy Worksheet Tab To A New WorkSheet

    What do you mean by looking up to an excel file in that worksheet?

  9. #9
    Registered User
    Join Date
    07-11-2012
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    91

    Re: VBA Code To Copy Worksheet Tab To A New WorkSheet

    to one cell that contains formulas for the updated date for example D:\Doc\Mar\Mar03

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Code To Copy Worksheet Tab To A New WorkSheet

    So you will have the text "D:\Doc\Mar\Mar03" entered in one particular cell of your sheet? Which cell?

  11. #11
    Registered User
    Join Date
    07-11-2012
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    91

    Re: VBA Code To Copy Worksheet Tab To A New WorkSheet

    C96 this is what i have so far:


    Sub SaveFile()

    Dim OutputFP As String

    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    ActiveSheet.Calculate

    OutputFP = Range("C96").Value

    Sheets(Array("Deleted Adjs", "Day1")).Select
    Sheets("Day1").Activate
    Sheets(Array("Deleted Adjs", "Day1")).Copy
    Sheets("Deleted Adjs").Select
    Range("A1:BZ100").Copy
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    Range("A1").Select

    Sheets("Day1").Select
    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    Range("A1").Select

    Sheets("Deleted Adjs").Select

    'Save File
    On Error GoTo ErrorRoutine
    ActiveWorkbook.SaveAs Filename:= _
    OutputFP _
    , FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
    ReadOnlyRecommended:=False, CreateBackup:=False
    MsgBox "File saved."
    Exit Sub

    ErrorRoutine:
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Application.Calculation = xlCalculationAutomatic
    MsgBox "File not saved."

    End Sub

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Code To Copy Worksheet Tab To A New WorkSheet

    Flani,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code in [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

+ 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