简体   繁体   English

根据单元格值在电子邮件中发送两个 Excel 范围

[英]Send two Excel ranges in email based on cell value

I found the following macro on a MicroSoft forum that does almost what I want.我在 MicroSoft 论坛上找到了以下宏,几乎可以满足我的需求。

I want to send two ranges of cells (A1:A20) and C1:F20) side by side in an email to a specific set of individuals based on whether a specific cell in the spreadsheet is less than 0.我想根据电子表格中的特定单元格是否小于 0,在电子邮件中将两个单元格范围 (A1:A20) 和 C1:F20) 并排发送给一组特定的个人。

I tried using different if statements.我尝试使用不同的 if 语句。 I get error messages.我收到错误消息。

Sub Send_Range()
       
    If (F187 < 0) Then
          
        ' Select the range of cells on the active worksheet.
        ActiveSheet.Range("A1:A20").Select
       
        ' Show the envelope on the ActiveWorkbook.
        ActiveWorkbook.EnvelopeVisible = True
       
       ' Set the optional introduction field thats adds
       ' some header text to the email body. It also sets
       ' the To and Subject lines. Finally the message
       ' is sent.
       With ActiveSheet.MailEnvelope
          .Introduction = "xxxxxxxxxx"
          .Item.To = "James@gmail.com"
          .Item.CC = "Alison@gmail.com"
          .Item.Subject = "Subject"
          .Item.Send
       End With
    
    End If
    
End Sub

See this, it shows how to copy a range into an email.看到这个,它显示了如何将范围复制到电子邮件中。 It might be what you need: Pasting an Excel range into an email as a picture这可能是您需要的: 将 Excel 范围作为图片粘贴到电子邮件中

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

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