0
我想创建一个If
/Then
声明,但我不确定如何执行此操作。如果根据一个值自动填充另一列的语句(Outlook:VBA)
下面是将UDF2设置为值<> str2然后从此列表中选择一个值的代码;这保存在UDF2中。
If str2 <> "" Then
Set objProperty = msg.UserProperties(udf(2))
If (objProperty Is Nothing) Then
Set objProperty = msg.UserProperties.Add(udf(2), olKeywords)
End If
objProperty.Value = str2
msg.Save
End If
谨以此做的是所选择的值存储在UDF2-如果所选择的值=“A”然后UDF2填充了值“A”,并且这也自动填充UDF3具有值“B”
下面是我试过的;我不确定代码应该在哪个订单中,或者这是否是If和Then条件的正确方法?
' save information in UDF2
If str2 <> "" Then
Set objProperty = msg.UserProperties(udf(2))
Else
If str2 = "A" Then
'set UDF3 as the value B
Set objProperty = msg.UserProperties.Add(list(3), olKeywords)
If (objProperty Is Nothing) Then
Set objProperty = msg.UserProperties.Add(udf(2), olKeywords)
End If
objProperty.Value = str2
objProperty.Value = str3
msg.Save
End If