+ Reply to Thread
Results 1 to 10 of 10

VBA to send a worksheet to another workbook?

  1. #1
    Registered User
    Join Date
    02-18-2015
    Location
    Flower Mound, TX
    MS-Off Ver
    2013
    Posts
    32

    VBA to send a worksheet to another workbook?

    Hi Excel Pros,

    I have some code that I'm using to save a particular workbook's worksheet to a new workbook. It works great but what I'm wanting to know is if it's possible to save an individual sheet from multiple workbooks to a new workbook and have it retain the individual worksheets.

    Please Login or Register  to view this content.
    Basically, I need to modify this code to run across an individual worksheet in several workbooks and have these individual worksheets each saved to a new sheet in the new designated workbook. Is such a thing even possible?

    Thanks!

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: VBA to send a worksheet to another workbook?

    Yes- its possible
    Need a way to get a handle on the workbooks and individual worksheets
    (The easiest situation would be that the same sheets are being copied from each workbook and that those workbooks are all in the same folder, which contains nothing else)

    Are all the workbooks in the same folder? Are they the only ones there?
    If not obvious how do we identify to VBA which workbooks to open?

    Is it one sheet to be copied from each workbook?
    Is it always the first sheet?
    Do the sheets all have the same name?
    If not obvious how do we identify to VBA which worksheet(s) to copy in each workbook?
    Last edited by kev_; 04-06-2017 at 10:44 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Registered User
    Join Date
    02-18-2015
    Location
    Flower Mound, TX
    MS-Off Ver
    2013
    Posts
    32

    Re: VBA to send a worksheet to another workbook?

    Hi kev,

    Yes, all the workbooks are in the same folder and they are the only workbooks present in the folder.
    Yes, the sheets in these four workbooks are all named the same. For security purposes, they're named "New York City".
    Only one sheet is to be copied. The "New York City" sheet from each of the four workbooks. There are eight worksheets total in each of these four workbooks. The "New York City" sheet is the 7th sheet.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,265

    Re: VBA to send a worksheet to another workbook?

    Hi RedditGold

    Can you supply us:
    1. The names of the 4 workbooks and the folder they are in.
    2. The name of the workbook that the 4 New York sheets must be copied into.
    3. Must we rename the Sheets to New York1, New York2 etc
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  5. #5
    Registered User
    Join Date
    02-18-2015
    Location
    Flower Mound, TX
    MS-Off Ver
    2013
    Posts
    32

    Re: VBA to send a worksheet to another workbook?

    Hi,

    The name of the folder is 'Total Cost 2017' and the name of the four workbooks are

    47_New_York_State_1
    47_New_York_State_2
    47_New_York_State_3
    47_New_York_State_4

    The name of the new workbook can simply be 'All New York'

    The sheets can be renamed anything. That naming convention works fine: New York1, New York2, etc.

    Thanks!

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: VBA to send a worksheet to another workbook?

    Try this

    AMEND:
    fileFolder = where the 4 files are
    myPath = where the new file is to be saved to
    myFile = new file name
    .Name = "NYC" & x ( each sheet needs a different name)


    Please Login or Register  to view this content.
    EDIT:
    I added a variable late and forgot to amend the code fully


    This line:
    Please Login or Register  to view this content.
    should now be:
    Please Login or Register  to view this content.
    Last edited by kev_; 04-06-2017 at 02:41 PM. Reason: amend code

  7. #7
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: VBA to send a worksheet to another workbook?

    @sintek - file names not required - it is every file in one folder
    Last edited by kev_; 04-06-2017 at 01:12 PM.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,265

    Re: VBA to send a worksheet to another workbook?

    @ kev_

    Thanks once again for the lessons....Need to go through this one in more detail...A lot I do not understand.

  9. #9
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: VBA to send a worksheet to another workbook?

    @sintek DIR function is very useful - look here for several examples

  10. #10
    Registered User
    Join Date
    02-18-2015
    Location
    Flower Mound, TX
    MS-Off Ver
    2013
    Posts
    32

    Re: VBA to send a worksheet to another workbook?

    Thanks for the help guys. I'll see if I can get this working!

+ 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. [SOLVED] Send out one Excel worksheet from the workbook
    By jackson_hollon in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-01-2016, 02:18 AM
  2. VBA code to copy data from current workbook to another workbook and send email
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-05-2015, 06:47 AM
  3. [SOLVED] cdo send send mail - getting my external .vbs script directly into a an excel worksheet
    By PieterBlan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-09-2014, 08:10 AM
  4. send each worksheet in workbook
    By 13lack13lade in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2013, 10:15 PM
  5. Send text from Word to active workbook/worksheet
    By silj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2013, 11:06 PM
  6. Script to Send a Single Worksheet from a Workbook via Email Based on a Cell Value
    By cstavr1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-22-2012, 04:00 PM
  7. command button VBA to send automated email not workbook or worksheet
    By lpratt in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-08-2012, 11:13 PM

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