• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA - Find the filter date for the subject line in email.


With the below code I am sending the email from outlook with the selected cells as an image.

In the subject as per code, today date is showing. Instead of today's date, I want to show the selected date through a filter.

Eg: If I filter 04-Feb-2020 then the subject should show 04-Feb-2020.

If I did not filter any dates, selecting and sending full month date then it should show "The report for the month of February 2020"

Please do the needful.

Sub Send_Selection_Or_ActiveSheet_with_MailEnvelope()
'Working in Excel 2002-2016
    Dim Sendrng As Range
    On Error GoTo StopMacro

    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With

    'Note: if the selection is one cell it will send the whole worksheet
    Set Sendrng = Selection
    'Create the mail and send it
    With Sendrng

        ActiveWorkbook.EnvelopeVisible = True
        With .Parent.MailEnvelope

            ' Set the optional introduction field thats adds
            ' some header text to the email body.
            .Introduction = "Find below the pick-up log details"

            With .Item
                .To = "xxxxx@xxx.xxx" ' modify email-address as needed
                .CC = ""
                .BCC = ""
                .Subject = "PICK-UP LOG Details " & Format(Date, "dd-mmm-yyyy")
            End With

        End With
    End With

    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
    ActiveWorkbook.EnvelopeVisible = False

End Sub


Last edited by a moderator:


Excel Ninja
Was Your 'activecell' in DATE ( "C1" )
Filtering ... selecting ... date
... if header-text has selected ... then ... date is DATE-text
... not those dates which are within rows 18..23 ... or how?