![](/img/trans.png)
[英]Send email from cell value google sheet, with other columns in email
[英]Send email from changed cell value from multiple offset rows
當單元格值在Excel跟蹤儀表板中的多個偏移量行彼此相距9,0時,我需要發送電子郵件。
我嘗試為“相交”定義偏移范圍,但是代碼無法與我輸入的內容一起運行。 同樣,我無法將此知識轉移到電子郵件主題行以獲取電子郵件的抵消客戶數據。
Dim xRg As Range
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Cells.Count > 1 Then Exit Sub
Set xRg = Intersect(Range("J13"), Target)
If xRg Is Nothing Then Exit Sub
If IsDate(Target.Value) And Target.Value > 0 Then
Call Mail_small_Text_Outlook
End If
End Sub
Sub Mail_small_Text_Outlook()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Hello" & vbNewLine & vbNewLine & _
"This client is now Committed & Complete and ready for your attention" & vbNewLine & vbNewLine & _
"Renew As Is?" & vbNewLine & _
"Adding Changing Groups?"
On Error Resume Next
With xOutMail
.To = "abc@xyz.com;IDCardTeam@xyz.com"
.CC = ""
.BCC = ""
.Subject = "Committed & Complete" & " " & Range("B9").Value & " " & Range("C9").Value
.Body = xMailBody
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
每當目標單元格輸入日期時,我都需要工作表發送電子郵件,並獲取相關的cusotmer信息以填充電子郵件。
我不太清楚Mail子項在哪里指向目標或偏移量,但是請嘗試以下操作:
編輯:出於完整性的考慮,這是經過測試的代碼
Dim targetRow As Long
Dim offsetRow As Long
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Cells.Count > 1 Then Exit Sub
' not required Set xRg = Intersect(Range("J13"), Target)
If Not Intersect(Target, Range("J13:J5000")) Is Nothing Then
If IsDate(Target.Value) And Target.Value > 0 Then
targetRow = Target.Row
offsetRow = Target.Offset(9, 0).Row
Call something(targetRow, offsetRow)
End If
End If
End Sub
Sub something(a As Long, b As Long)
Debug.Print "This is a " & a & " and " & b
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.