0

I found the following macro on a MicroSoft forum that does almost what I want.

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.

I tried using different if statements. 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
Community
  • 1
  • 1
  • What kind of errors are you getting? Also show us the IF statements you're using. – PKatona Jun 20 '18 at 17:45
  • If you're checking cell F187, your syntax should be `If Sheets("YourSheetName").Range("F187")...` – BigBen Jun 20 '18 at 19:26
  • Also, if you're going to use `MailEnvelope`, the only way I've found to send 2 ranges side by side is to send the entire range, hiding Column B (which could be unhidden by the email recipients). – BigBen Jun 20 '18 at 20:00

1 Answers1

0

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

PKatona
  • 629
  • 2
  • 9
  • 19