+ Reply to Thread
Results 1 to 5 of 5

Sending Email Attachments by Data

Hybrid View

  1. #1
    Registered User
    Join Date
    07-16-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    4

    Sending Email Attachments by Data

    hello all,

    im new here and looking for some help.

    bascially, i have a long list of dat for each department which i would like to paste into sheet 1.

    this then needs to be filtered by column H (department name) and copied into sheet 2's template.

    once in the template, i need to send this to the relevant email address in sheet 3.

    this needs to be done for all departments.

    please could someone either assist or point me in the right direction.

    also posted on
    HTML Code: 
    but no one seems to respond there...

    thanks,

    adam
    Last edited by Adzg91; 08-24-2014 at 04:09 AM.

  2. #2
    Registered User
    Join Date
    07-16-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    4

    Re: Sending Email Attachments by Data

    anyone able to assist?

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Sending Email Attachments by Data

    I am afraid that your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  4. #4
    Registered User
    Join Date
    07-16-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    4

    Re: Sending Email Attachments by Data

    this has now been added, please oculd someone take a look as im struggling to find the best way to filter the departments and ensure that none are missed.

    thanks

  5. #5
    Registered User
    Join Date
    07-16-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    4

    Re: Sending Email Attachments by Data

    UPDATE: I have found the following code with filters the data perfectly but i need to alter it so instead of creating a new worksheet it sends the worksheet as an attachement to the email address in sheet 3. Would appreciate some help

    Sub t()
     Dim ws1Master As Worksheet, wsNew As Worksheet, wsFilter As Worksheet
        Dim Datarng As Range, FilterRange As Range, objRange As Range
        Dim rowcount As Long
        Dim colcount As Integer, FilterCol As Integer
        Dim SheetName As String
        
        
        Set ws1Master = ActiveSheet
    
    top:
    
        On Error Resume Next
        Set objRange = Application.InputBox("Select Field Name To Filter", "Range Input", , , , , , 8)
        On Error GoTo 0
        If objRange Is Nothing Then
            Exit Sub
        ElseIf objRange.Columns.Count > 1 Then
            GoTo top
        End If
        FilterCol = objRange.Column
        With Application
            .ScreenUpdating = False
            .DisplayAlerts = False
        End With
        On Error GoTo progend
        'add filter sheet
        Set wsFilter = Sheets.Add
        With ws1Master
            .Activate
            .Unprotect Password:=""  'add password if needed
            rowcount = .Cells(.Rows.Count, FilterCol).End(xlUp).Row
            colcount = .Cells(1, .Columns.Count).End(xlToLeft).Column
            If FilterCol > colcount Then
                Err.Raise 65000, "", "FilterCol Setting Is Outside Data Range.", "", 0
            End If
            Set Datarng = .Range(.Cells(1, 1), .Cells(rowcount, colcount))
            'extract Unique values from FilterCol
            .Range(.Cells(1, FilterCol), _
                   .Cells(rowcount, _
                          FilterCol)).AdvancedFilter _
                          Action:=xlFilterCopy, _
                          CopyToRange:=wsFilter.Range("A1"), _
                          Unique:=True
            rowcount = wsFilter.Cells(wsFilter.Rows.Count, "A").End(xlUp).Row
            'set Criteria
            wsFilter.Range("B1").Value = wsFilter.Range("A1").Value
            For Each FilterRange In wsFilter.Range("A2:A" & rowcount)
                'check for blank cell in range
                If Len(FilterRange.Value) > 0 Then
                    'add the FilterRange to criteria
                    wsFilter.Range("B2").Value = FilterRange.Value
                    SheetName = RTrim(Left(FilterRange.Value, 31))
                    'if FilterRange sheet exists
                    'update it
                    If SheetExists(SheetName) Then
                        Sheets(SheetName).Cells.Clear
                    Else
                        'add new sheet
                        Set wsNew = Sheets.Add
                        wsNew.Move After:=Worksheets(Worksheets.Count)
                        wsNew.Name = SheetName
                    End If
                    Datarng.AdvancedFilter Action:=xlFilterCopy, _
                                           CriteriaRange:=wsFilter.Range("B1:B2"), _
                                           CopyToRange:=Sheets(SheetName).Range("A1"), _
                                           Unique:=False
                End If
            Next
            .Select
        End With
    progend:
        wsFilter.Delete
        With Application
            .ScreenUpdating = True
            .DisplayAlerts = True
        End With
        If Err > 0 Then
            MsgBox (Error(Err)), vbCritical, "Error"
            Err.Clear
        End If
    End Sub
    
    
    Function SheetExists(wksName As String) As Boolean
        On Error Resume Next
        SheetExists = CBool(Len(Worksheets(wksName).Name) > 0)
        On Error GoTo 0
    End Function
    End Function

+ 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. Sending Email with Multiple Attachments from Excel
    By Lisa4legin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-29-2013, 03:24 PM
  2. Replies: 0
    Last Post: 09-22-2012, 10:06 AM
  3. Attachments when sending mails with excel
    By Steffen Thomsen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2011, 05:27 AM
  4. Sending Outlook Attachments with VBA
    By nms2130 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2011, 12:36 PM
  5. Problem in Sending Large Attachments
    By Webtekr in forum Outlook Formatting & Functions
    Replies: 2
    Last Post: 03-06-2009, 07:17 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