繁体   English   中英

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

[英]VBA code for multiply ranges from more than one Sheet

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

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
        dim myVariable as string
        dim newRange as string
        newRange = Range.Value 
        myVariable = myVariable + newRange

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM