Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

excel - Add x number of days to a cell date value from a Pivot Table

I have created an auto mailer where my goal is to add X number of days to the reference date value and will send the email based on the output value in the Pivot Table using Macro but i am kind of got stuck from the code i have created below. For example, D16 contains 04/02/2021, macro should be able to read and add 15 days if X = 15 then it will send an email on 19/02/2021. Any advice or help is appreciated.

Sub email()

    Dim r As Range
    Dim cell As Range

    Set r = Range("D16")

    For Each cell In r

        If cell.Value <> "" Then

            Dim Email_Subject, Email_Send_From, Email_Send_To, _
            Email_Cc, Email_Bcc, Email_Body As String
            Dim Mail_Object, Mail_Single As Variant

            Email_Subject = "subject"
            Email_Send_From = "[email protected]"
            Email_Send_To = "[email protected]"
            Email_Body = "sdsdsdsdsdy"

            'On Error GoTo debugs
            
            Set Mail_Object = CreateObject("Outlook.Application")
            Set Mail_Single = Mail_Object.CreateItem(0)
            With Mail_Single
            .Subject = Email_Subject
            .To = Email_Send_To
            .cc = Email_Cc
            .BCC = Email_Bcc
            .Body = Email_Body
            '.display
            .send
            End With

        End If

Next


Exit Sub

'debugs:
        'If Err.Description <> "" Then MsgBox Err.Description
End Sub
question from:https://stackoverflow.com/questions/66048226/add-x-number-of-days-to-a-cell-date-value-from-a-pivot-table

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...