我有这个工作代码:
If Not Intersect(ActiveCell, Range("D6:D15")) Is Nothing Then
MsgBox "busses"
Else
MsgBox "Select Only Cells With Asset ID", vbCritical
Exit Sub
End If
我想在该行中添加更多范围,如下所示:
If Not Intersect(ActiveCell, Range("D6:D15") Or ("G6:G15") Or ("J6:J15")) Is Nothing Then
MsgBox "busses"
Else
MsgBox "Select Only Cells With Asset ID", vbCritical
Exit Sub
End If
您可以定义由不同单元格组成的范围:
If Not Intersect(ActiveCell, Range("D6:D15,G6:G15,J6:J15")) Is Nothing Then
MsgBox "busses"
Else
MsgBox "Select Only Cells With Asset ID", vbCritical
Exit Sub
End If