Closed Thread
Results 1 to 3 of 3

Create Worksheet/Workbook and email through Macro

  1. #1
    Registered User
    Join Date
    12-01-2008
    Location
    India
    MS-Off Ver
    Microsoft 365 Enterprise - Excel version2301
    Posts
    63

    Create Worksheet/Workbook and email through Macro

    Hi

    I need help on a Macro.

    I have an Excel file wherein I have three tabs "List", "Template", "PO Report". Template is linked to PO Report and in the List I have number of Cost Centers in Column A. What i need is to create a copy of Template as per the list ( which will be fluctuating) in the LIST tab. Rename the tabs created as per List ( Cost Centers).-----(1)

    Secondly i want to create separate file for each of the tab created with tab name.----(2)

    Thirdly a Macro to email each work sheet created at (1) or file created at (2) as per the list to separate Cost Center owners.


    For First i am using the below code, the problem with this is everyday list of cost center increases/decreases i have change the number of cost centers in the code for which tabs to be created . It should automaticaly pick the Cost Center from the list until blank cell is found.
    Option Explicit

    Sub Copy_Sheets()

    Dim i As Integer
    Dim wks As Worksheet

    Set wks = Sheets("List")

    For i = 1 To 6
    Sheets("Template").Copy After:=Sheets(2)
    ActiveSheet.Name = wks.Cells(i, 1)
    ActiveSheet.Cells(1, 2) = wks.Cells(i, 1)
    Next

    End Sub


    For (2) I am using the below code, the problem with this is it creates a file of all the tabs in the file i.e. It creates a separate file for "LIST", "Template" and "PO Report" as well. It should only create file of cost centers as per the List only.

    Sub SaveEachWS()
    Dim ws As Worksheet

    For Each ws In ThisWorkbook.Worksheets
    ws.Copy
    ActiveWorkbook.SaveAs Filename:=ws.Name
    ActiveWorkbook.Close
    Next ws

    End Sub

    For (3)

    I could not create code, It should email the tabs / files created from the email address in a partcular cell it may be A1 or D2 anything.


    Thanks in advance for all you help on this.
    Amar

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Create Worksheet/Workbook and email through Macro

    Hi, Amar ,

    Your post does not comply with Rule 3 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 here

    ----

    Please do not start new threads regarding the same subject (Rule #5) - http://www.excelforum.com/excel-prog...and-email.html.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  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: Create Worksheet/Workbook and email through Macro

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.
    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]

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to PDF a sheet in workbook and email (outlook) to an email address in a cell
    By paul_sykes00 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-17-2012, 12:54 AM
  2. [SOLVED] Create macro to send worksheet as body of email using cells as subject line
    By LindaABH in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-16-2012, 07:43 PM
  3. Macro will not create new worksheet and workbook
    By fmluder93 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-01-2009, 05:08 PM
  4. Macro to Create Worksheet 'xxxx' and list All Worksheets in Workbook
    By R_S_6 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-02-2009, 08:58 AM
  5. email worksheet rather than workbook from macro
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-22-2008, 09:23 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