用于乘法的VBA代码来自多个工作表

时间:2017-04-05 16:21:56

标签: vba excel-vba excel

我正在训练编写VBA代码,将两张数据包发送到一封电子邮件并发送。 我使用下面的代码进行调试但是我没有一次又一次地这么做。 下面的代码发送一个工作表范围数据,我想从sheet2 (Worksheets("Sheet2").Range("b3:b30")

添加额外的rage
Sub Mail_take_2()

    Dim AWorksheet As Worksheet
    Dim Sendrng As Range
    Dim rng As Range

    On Error GoTo StopMacro

    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With
    Set Sendrng = Worksheets("Sheet1").Range("c2:j45")

    Set AWorksheet = ActiveSheet

    With Sendrng

        .Parent.Select

        Set rng = ActiveCell

        .Select

        ActiveWorkbook.EnvelopeVisible = True
        With .Parent.MailEnvelope

            .Introduction = "This is test mail 2."

            With .Item
                .To = "aaa@aa.com"
                .CC = ""
                .BCC = ""
                .Subject = "My subject"
                .Send
            End With

        End With

        rng.Select
    End With

    AWorksheet.Select

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

End Sub

1 个答案:

答案 0 :(得分:0)

FileTimeToSystemTime

这有助于你弄清楚你想要做什么吗?