我正在尝试根据条件( MainR或CC)选择具有固定范围 C6:C11 的收件人电子邮件地址( C列) )在(列D )固定范围中定义,以及 D6:D11 ,然后将它们添加为主要收件人或抄送收件人。
我的代码适用于一个固定范围( C列) C6:C11 。对于该列中的每个单元格。如果电子邮件地址的字符串中包含“@”,它会将单元格选为收件人。
以下示例:
$ ./manage.py test animals/
我希望切换当前范围( C6:C11 ),其范围包含我的关键字( D6:D11 )。对于该列中的每个 MainR或CC ,宏应使用( C列 C6:C11 )中的相邻电子邮件地址。
完整代码:
Set xRg = Sheet1.Range("C6:C11")
Set xOTApp = CreateObject("Outlook.Application")
For Each xCell In xRg
If xCell.Value Like "*@*" Then
If xEmailAddr = "" Then
xEmailAddr = xCell.Value
Else
xEmailAddr = xEmailAddr & ";" & xCell.Value
End If
End If
Next
答案 0 :(得分:0)
您应该可以通过在单个FOR
循环中组合地址集合来实现这一目标:
For Each xCell In xRg
If xCell.Value Like "*@*" Then
If LCase(Trim(Sheet1.Range("D"& xCell.Row).Value)) = "mainr" Then
If xEmailAddr = "" Then
xEmailAddr = xCell.Value
Else
xEmailAddr = xEmailAddr & ";" & xCell.Value
End If
ElseIf LCase(Trim(Sheet1.Range("D"& xCell.Row).Value)) = "cc" Then
If zEmailAddr = "" Then
zEmailAddr = xCell.Value
Else
zEmailAddr = zEmailAddr & ";" & xCell.Value
End If
Else
<your error handling here for unexpected value in D range>
End If
End If
Next
作为旁注,我会从函数中删除On Error Resume Next
,因为它往往会隐藏在调试时不利的错误
答案 1 :(得分:0)
您可以使用public class RVAdapter extends RecyclerView.Adapter<RVAdapter.LessonCardViewHolder> {
:
// import here your view holder
public class RVAdapter extends RecyclerView.Adapter<LessonCardViewHolder> {