+ Reply to Thread
Results 1 to 4 of 4

(No Macro Experience) Emailing each tab in a workbook

  1. #1
    Registered User
    Join Date
    05-08-2015
    Location
    Middle of Nowhere
    MS-Off Ver
    2010
    Posts
    38

    (No Macro Experience) Emailing each tab in a workbook

    Good Morning,

    I have a workbook with 40 tabs, each tab needs to go to a different person. Each tab has their name on the tab. There was a macro setup in this workbook to save each file individually to be emailed. Instead of going back to the person that set it up I would like to learn myself.

    Is this a simple process, that you can explain?

    I have attached a sample worksheet with the data on it.

    Thanks so much in advance for any assistance you can provide.
    Attached Files Attached Files

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

    Re: (No Macro Experience) Emailing each tab in a workbook

    Hi sevanseriesta
    This will give you an idea...What it does is as follows:
    Loops through all sheets one at a time, copies sheet to newbook and saves on desktop
    Add as attachment and emails to recipient....email address found in the sheet in Range("D1")
    Deleted the file and then loops to next sheet doing the same....
    have a look at attached sample.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    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!!!

  3. #3
    Registered User
    Join Date
    05-08-2015
    Location
    Middle of Nowhere
    MS-Off Ver
    2010
    Posts
    38

    Re: (No Macro Experience) Emailing each tab in a workbook

    Sintec,

    Thanks so much for your quick response. Since I'm new to the macro scripts I will see if I can get this to work without corrupting the data. I will update with my changes, to see if it will do what I want or if I mess it up.

    Thanks again for your help.

  4. #4
    Registered User
    Join Date
    05-08-2015
    Location
    Middle of Nowhere
    MS-Off Ver
    2010
    Posts
    38

    Re: (No Macro Experience) Emailing each tab in a workbook

    Here is my current Macro, I didn't write it so I don't understand what anything means. This is making it very difficult for me to change what needs to be changed in the above script. Everytime I alter it I get an error when I try to run the macro.

    Here is the script.

    Sub SplitWorkbookbyTab()
    'Updateby20140612
    Dim FileExtStr As String, fnam As String
    Dim FileFormatNum As Long
    Dim xWs As Worksheet
    Dim xWb As Workbook
    Dim FolderName As String
    Application.ScreenUpdating = False
    Set xWb = Application.ThisWorkbook
    DateString = Format(Now, "yyyy-mm-dd hh-mm-ss")
    FolderName = xWb.Path & "\" & xWb.Name & " " & DateString
    MkDir FolderName
    For Each xWs In xWb.Worksheets
    xWs.Copy
    fnam = xWs.Name & " AR Aging"
    If Val(Application.Version) < 12 Then
    FileExtStr = ".xls": FileFormatNum = -4143
    Else
    Select Case xWb.FileFormat
    Case 51:
    FileExtStr = ".xlsx": FileFormatNum = 51
    Case 52:
    If Application.ActiveWorkbook.HasVBProject Then
    FileExtStr = ".xlsm": FileFormatNum = 52
    Else
    FileExtStr = ".xlsx": FileFormatNum = 51
    End If
    Case 56:
    FileExtStr = ".xls": FileFormatNum = 56
    Case Else:
    FileExtStr = ".xlsb": FileFormatNum = 50
    End Select
    End If
    xFile = FolderName & "\" & fnam & FileExtStr
    Application.ActiveWorkbook.SaveAs xFile, FileFormat:=FileFormatNum
    Application.ActiveWorkbook.Close False
    Next
    MsgBox "You can find the files in " & FolderName
    Application.ScreenUpdating = True
    End Sub


    This is the script you gave me an I edited it. ( I can't get it to work)

    Option Explicit
    Sub EmailSheet()
    Dim recipient As String, subject As String
    Dim ws As Worksheet
    Dim newWorkbook As Workbook
    Application.ScreenUpdating = False

    For Each ws In ActiveWorkbook.Sheets
    Set newWorkbook = Excel.Workbooks.Add
    ws.Copy newWorkbook.Sheets(newWorkbook.Sheets.Count)
    newWorkbook.SaveAs "X:\Monthly Reporting\Management Accounts\CLUS\Weekly AR Reporting\MCL AR Reports" & ws.Name & ".xlsx"
    With CreateObject("outlook.application").CreateItem(0)
    .To = ActiveSheet.Range("D1")
    .subject = "Open AR"
    .body = "Good Day, Attached you will find the open AR for your accounts. If you have any questions please contact your Account Rep"
    .Attachments.Add "C:\Users\Sintek\Desktop\" & ws.Name & ".xls"
    .send
    End With
    ActiveWorkbook.Close saveChanges:=False
    Kill "X:\Monthly Reporting\Management Accounts\CLUS\Weekly AR Reporting\MCL AR Reports" & ws.Name & ".xlsx"
    Next ws

    Application.ScreenUpdating = True
    End Sub
    Last edited by sevanseriesta; 05-19-2017 at 01:52 PM.

+ 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. improve macro and user experience with options
    By AkaTrouble in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-25-2014, 10:19 AM
  2. [SOLVED] No Experience – Need a specific copy and paste macro
    By shuynh84 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-31-2014, 03:15 PM
  3. [SOLVED] No Macro Experience - Need to run a loop (I think?!) over a set of data for multiple rows
    By vkelly in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-29-2014, 08:11 AM
  4. error with macro for emailing workbook with lotus notes
    By mikeydaman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-09-2013, 12:21 PM
  5. Emailing workbook which is already a macro output !
    By amlan009 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-01-2012, 11:01 AM
  6. Replies: 5
    Last Post: 11-27-2009, 12:47 PM
  7. [SOLVED] Using macro to stop user from emailing workbook
    By scooppbear in forum Excel General
    Replies: 1
    Last Post: 05-17-2006, 12:43 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