从行中的另一列获取单元格信息

我如何设置,使收件人姓名的电子邮件地址是从不同的列中获取的。

我列出的名字写在一列,我想检查每个人在同一行的date,如果它的1个月,然后发送电子邮件给该人。 我只能引用一个特定的单元格,但是我需要为每一行迭代P列。

Sub Workbook_Open() Dim Cell As Range Dim objDate As Date For Each Cell In Range("P3:P4").Cells If Cell.Value <= Date + 30 Then 'MsgBox "Going to expire in 1 month" Dim appOutlook As Outlook.Application Dim mitOutlookMsg As Outlook.MailItem Dim recOutlookRecip As Outlook.Recipient ' Step 1: Initialize an Outlook session. Set appOutlook = CreateObject("Outlook.Application") ' Step 2: Create a new message. Set mitOutlookMsg = appOutlook.CreateItem(olMailItem) With mitOutlookMsg ' Step3: Add the To recipient(s) to message. Set recOutlookRecip = .Recipients.Add(Cells(3, 2)) recOutlookRecip.Type = olTo 'Set valid properties like Subject, Body, and Importance of the message. .Subject = "Test123" '.Body = "Test" .BodyFormat = olFormatHTML .HTMLBody = " TEST EMAIL " .Importance = olImportanceHigh 'High importance ' Resolve every Recipient's name For Each recOutlookRecip In .Recipients recOutlookRecip.Resolve If Not recOutlookRecip.Resolve Then mitOutlookMsg.Display End If Next .Send End With Set mitOutlookMsg = Nothing Set appOutlook = Nothing Else End If Next Cell End Sub 

我想你要找的是:Range.Offset(row,col)

例如:

  For Each Cell In Range("P3:P4").Cells 'cell.Value refers to P3:P4 myDate = cell.Value 'cell.Offset(0, 1).Value refers to the column one to the right of cell myName = cell.Offset(0, 1).Value Next cell