If InStr(1, tmp, Arr(1, 1)) Or InStr(1, tmp, Arr(2, 1)) Or InStr(1, tmp, Arr(3, 1)) Then
'如果这个单元格含有( a 或 b 或 c ),执行的动作写这里
End If
Next
End With
End Sub
7.求以下的VBA代码怎样写 操作方法: 在工作表标签上点鼠标右键,选择“查看代码”,在弹出的窗口中粘贴以下内容,你的工作表就具有你想要的功能了: Option ExplicitPrivate Sub Worksheet_Change(ByVal Target As Range) Dim c As Range, x As Long, y As Long, s As String For Each c In Target.Cells x = c.Column If x = 5 Then y = c.Row If InStr(c.Value, "CE Material") <> 0 And InStr(c.Value, "E/") <> 0 Then s = "正常项目/MOD1" ElseIf InStr(c.Value, "MOD Material") <> 0 And InStr(c.Value, "M/") <> 0 Then s = "正常项目/MOD1" ElseIf InStr(c.Value, "CS Material") <> 0 Then s = "CS/SPC" Else s = "其它" End If Cells(y, "A") = s End If Next cEnd Sub 。
文章插图