我需要根据 2 个单元格是否包含特定值来自动填充单元格,然后自动运行它。这是我目前所拥有的:
Private Sub Worksheet_Change(ByVal Target As Range)
If target.Cells(5, "B").Value = "Secured" And target.Cells(6, "B").Value = "Amendment" Then
Cells(10, "B") = "T2 - Medium Risk"
End If
End Sub
if 语句应该这样=IF(AND(D34="Secured",D35="Amendment"),"yes","")
,但“是”需要放在不同的单元格中
答案1
这就是你要找的
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B5:B6")) Is Nothing Then
If Cells(5, 2) = "Secured" And Cells(6, 2) = "Amendment" Then
Cells(10, 2) = "T2 - Medium Risk"
End If
End If
End Sub
您希望它在更改发生在这两个单元格内时触发,如果它们匹配,则填充另一个单元格。如果您想删除它,您也可以这样做。