+ Reply to Thread
Results 1 to 17 of 17

VBA to Create new workbook with 2 worksheet and save 10 times then send all via outlook

  1. #1
    Registered User
    Join Date
    09-17-2018
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    17

    VBA to Create new workbook with 2 worksheet and save 10 times then send all via outlook

    Help PLEASE - I have a workbook with 30 odd worksheets, I am trying to get 2 worksheets to copy and save into new workbook 10 times and then attach the new workbooks to email (Outlook ) to send.

    For Example: the below code does what i want for the 2 worksheets with the correct name of the file but won't work through the rest...

    Please Login or Register  to view this content.
    Last edited by alansidman; 09-24-2018 at 01:05 AM.

  2. #2
    Registered User
    Join Date
    09-17-2018
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    17

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    Copy of sheet attached
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    09-17-2018
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    17

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    Please Help - I'm self taught in VBA so don't know the in and outs.
    Even if I could get the 2 worksheets to a new workbook and then email, I would create a button on each sheet to do this, just means I would have to send 10 different emails.
    I have spent the best part of the last 3 days trying different things and running them through marcos and trying to debug, just can't get it right...

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    Code Tags Added
    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [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 at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Registered User
    Join Date
    09-17-2018
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    17

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    Alan - Tried to do this but I kept getting error message saying - I was unable to post links or images until I had most post ??
    Thanks - I'm new to all this but I will try to comply best I can.

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

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    Morning Chris76

    Seems to me all you need to do is make one copy only and mail to 10 different users...is this correct...herewith an example of how it could work...saving the email addresses and recipient names in a sheet...

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 09-24-2018 at 02:35 AM.
    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!!!

  7. #7
    Registered User
    Join Date
    09-17-2018
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    17

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    Sintek -Thanks for the reply...here is code I have, I just can't debug it, must be doing something wrong, yours would work for 1 but I have 10 to extract the same way and emails go to the same people each time..

    Please Login or Register  to view this content.

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

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    So...You are wanting to copy 2 x different worksheets each time to a new workbook...10 times
    Please Login or Register  to view this content.
    And send to 10 different recipients...
    Where are the email cc, bcc addresses of the recipients stored...
    The attached PDF
    but yet you are saving as a macro-enabled workbook not pdf
    Last edited by sintek; 09-25-2018 at 02:27 AM.

  9. #9
    Registered User
    Join Date
    09-17-2018
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    17

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    Sintek - Yes - Your code works great but I get a download error on the attachment in the email when it opens up, I get the 10 Emails with the correct attachments which is great but get this download error... The emails will go to the same people each time, but that is an easy fix with your code. Just don't why I am getting a download error ??
    The files are saving to a share point file in office ?? do you know of any problems with doing this ??? Maybe if I changed it to a "C:/" Drive location I wouldn't get the download error..

    Any thoughts ??Download Error View.docx

  10. #10
    Registered User
    Join Date
    09-17-2018
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    17

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    I had this code for PDF but they, the " governing body " wants the original macro-enabled workbooks and I just couldn't work out the change,...

    With your code when I go back into the file location the files are their created as expected with the correct file names, just getting the download error on the emails, worst case I will just modify your to code just do the files and do the emails manually now that I have files extracted and saved quickly but would rather that the VBA works and do it with one hit of the button and i'm done

    Thanks for your help...

  11. #11
    Registered User
    Join Date
    09-17-2018
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    17

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    Sintek - Just a quick question, Is there anyway to modify the code so that it opens just 1 email with the 10 attachments in it, instead of 10 emails with 1 attachment in each email ??
    This would be a perfect fit for me if we can do this ...

    Cheers and Thanks again for everyone's help...

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

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    Is your code is within the workbook that contains all the sheets...
    And this workbook is saved in your particular path...
    Is there anyway to modify the code so that it opens just 1 email with the 10 attachments in it, instead of 10 emails with 1 attachment in each email ?
    Yes, this can easily be achieved...Something like this...Untested...Pls upload a sample file which contains all the sheets so that we can make use of for testing...
    Please Login or Register  to view this content.
    Last edited by sintek; 09-25-2018 at 08:43 AM.

  13. #13
    Registered User
    Join Date
    09-17-2018
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    17

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    SINTEK - Awesome Stuff your code work a charm, Thanks for the help

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

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    Pleasure...
    If you feel I have helped, please click on the star to left of post [Add Reputation]

  15. #15
    Registered User
    Join Date
    09-17-2018
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    17

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    SINTEK HELP - When I run the code everything works fine EXCEPT for the attached sheets to the correct File.

    The below is a list of the excel files generated by the code, which is CORRECT for the File Names but the sheets in each File doesn't correspond to the correct Files Name, except for the first one in the code "Binalong"

    Binalong 2019 SWDBA Pennants Player Participation Record 18-Oct-18.xlsm - THE ONLY FILE THAT IS CORRECT - ATTACHED SHEETS ARE -
    "Binalong Details", "Binalong Player_Records"

    Boorowa Rec 2019 SWDBA Pennants Player Participation Record 18-Oct-18.xlsm - INCORRECT - ATTACHED SHEETS ARE -
    "Bwa Rec Details", "Binalong Player_Records"

    Boorowa Ex 2019 SWDBA Pennants Player Participation Record 18-Oct-18.xlsm - INCORRECT - ATTACHED SHEETS ARE -
    "Bwa Rec Details", "Bwa Rec Player_Records"

    Bribbaree 2019 SWDBA Pennants Player Participation Record 18-Oct-18.xlsm - INCORRECT - ATTACHED SHEETS ARE -
    "Bwa Ex Details", "Bwa Rec Player_Records"

    Cootamundra 2019 SWDBA Pennants Player Participation Record 18-Oct-18.xlsm - INCORRECT - ATTACHED SHEETS ARE -
    "Bwa Ex Details", "Bwa Ex Player_Records"

    Cootamundra Ex 2019 SWDBA Pennants Player Participation Record 18-Oct-18.xlsm - INCORRECT - ATTACHED SHEETS ARE -
    "Bribbaree Details", "Bwa Ex Player_Records"

    Harden 2019 SWDBA Pennants Player Participation Record 18-Oct-18.xlsm - INCORRECT - ATTACHED SHEETS ARE -
    "Bribbaree Details", "Bribbaree Player_Records"

    Quandialla 2019 SWDBA Pennants Player Participation Record 18-Oct-18.xlsm - INCORRECT - ATTACHED SHEETS ARE -
    "Coota CC Details",, "Bribbaree Player_Records"

    Stockinbingal 2019 SWDBA Pennants Player Participation Record 18-Oct-18.xlsm - INCORRECT - ATTACHED SHEETS ARE -
    "Coota CC Details", "Coota CC Details"

    Young 2019 SWDBA Pennants Player Participation Record 18-Oct-18.xlsm - INCORRECT - ATTACHED SHEETS ARE -
    "Coota Ex Details", "Coota CC Details"


    I have tried to change the code around to get it work without luck, any help or ideas would be great....

    Code and File Attached for you




    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    09-17-2018
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    17

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    Can anyone help me correct the code above !!!

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

    Re: VBA to Create new workbook with 2 worksheet and save 10 times then send all via outloo

    As per previous requests...pls upload a sample file with the correct sheets that can be used for testing...
    Also...What is your expected outcome...
    Last edited by sintek; 10-19-2018 at 12:39 AM.

+ 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. Create Macro to copy worksheet into new workbook, change things& drop into Outlook
    By sspatriots in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-19-2017, 09:17 AM
  2. [SOLVED] Create, rename, and save new worksheet and workbook
    By peihsin.lee in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-15-2017, 05:04 AM
  3. [SOLVED] Events running multiple times per worksheet on workbook save
    By JimBobW in forum Excel General
    Replies: 4
    Last Post: 01-21-2016, 09:04 AM
  4. [SOLVED] need to save one worksheet into pdf and send via outlook
    By AWITCHER in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-24-2015, 09:41 AM
  5. [SOLVED] Create New Message in Outlook, Don't Send
    By athyeh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2014, 10:33 AM
  6. [SOLVED] Create button to Save specific page ranges from each worksheet in the workbook
    By projectatpel in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-16-2014, 02:22 PM
  7. Save range and send as outlook email
    By hejbeiter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-30-2012, 12:50 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