+ Reply to Thread
Results 1 to 6 of 6

VBA Code to export dynamic excel tabs to new workbook

Hybrid View

savetrees VBA Code to export dynamic... 11-18-2014, 09:27 AM
mike7952 Re: VBA Code to export... 11-18-2014, 10:12 AM
savetrees Re: VBA Code to export... 11-18-2014, 10:48 AM
savetrees Re: VBA Code to export... 11-18-2014, 11:24 AM
JOHN H. DAVIS Re: VBA Code to export... 11-18-2014, 11:51 AM
savetrees Re: VBA Code to export... 11-18-2014, 12:25 PM
  1. #1
    Registered User
    Join Date
    07-15-2014
    Location
    Netherlands
    MS-Off Ver
    2010
    Posts
    66

    VBA Code to export dynamic excel tabs to new workbook

    Hi,

    I have been looking through many threads to find out the Excel sheet export code, but wasn't lucky.

    Here is my requirement, i have multiple sheets in the attached with different name and it will keep adding as we progress. I need a vba code which should prompt me to ask which tabs to export to new workbook. Please help

    In the attached, i have created A,B,C,D & E tabs and the VBA code should prompt sheet names for me to select and export/move/copy to new workbook.
    Attached Files Attached Files

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: VBA Code to export dynamic excel tabs to new workbook

    See attached file for a start
    Attached Files Attached Files
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    07-15-2014
    Location
    Netherlands
    MS-Off Ver
    2010
    Posts
    66

    Re: VBA Code to export dynamic excel tabs to new workbook

    Thanks Mike this serves the purpose, i will play with my original file and let you know. many thanks

  4. #4
    Registered User
    Join Date
    07-15-2014
    Location
    Netherlands
    MS-Off Ver
    2010
    Posts
    66

    Re: VBA Code to export dynamic excel tabs to new workbook

    Mike,

    It worked well with minor tweaks and i was able to add my existing code for few more calculations and formatting. Thanks a lot

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

    Re: VBA Code to export dynamic excel tabs to new workbook

    Could you use something like this?

    Sub savetrees()
    Dim i As Long
    Dim y As String
    Dim x As Long
    Dim wbk As Workbook
    Application.DisplayAlerts = False
    Set wbk = ActiveWorkbook
    Sheets.Add.Name = "Export"
    Do Until MsgBox("Would you like to add another sheet too export", vbYesNo) = vbNo
        Sheets("Export").Range("A" & Rows.Count).End(3)(2) = InputBox("Please Enter A Sheet too Export")
    Loop
    Workbooks.Add
    ActiveWorkbook.SaveAs wbk.Path & "/" & "new workbook" & ".xls"
    x = ActiveWorkbook.Sheets.Count
    wbk.Sheets("Export").Activate
        For i = 2 To Range("A" & Rows.Count).End(3).Row
            y = Cells(i, "A").Value
            wbk.Sheets(y).Activate
            ActiveSheet.Copy after:=Workbooks("new workbook.xls").Sheets(x)
            wbk.Sheets("Export").Activate
        Next i
    wbk.Sheets("Export").Delete
    Application.DisplayAlerts = True
    End Sub

  6. #6
    Registered User
    Join Date
    07-15-2014
    Location
    Netherlands
    MS-Off Ver
    2010
    Posts
    66

    Re: VBA Code to export dynamic excel tabs to new workbook

    Thanks John, yes this solution also working fine, however Mike's input serves perfectly with my requirement. And thanks for your inputs as well ... ..

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy Tabs from different excel file by using code name of the tabs
    By varun.kalra1988 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-15-2014, 02:03 PM
  2. Is there a vba code to add mutiple workbooks into one workbook as tabs on the top?
    By DENISEG in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-13-2014, 12:18 PM
  3. Export Table to CSV (with code & workbook)
    By somebody113 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-01-2013, 03:58 AM
  4. Programmatically export the VBA code from an Excel workbook
    By Daryn in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-13-2010, 03:34 PM
  5. Export several excel tabs to pdf (or similar)
    By MarkFerdinandson in forum Excel General
    Replies: 7
    Last Post: 09-02-2009, 11:04 AM

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