|
发表于 2017-4-29 15:50
|
显示全部楼层
本楼为最佳答案
本帖最后由 327718098 于 2017-5-4 07:24 编辑
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents=False
If Target.Count > 1 Then
MsgBox "不能选中多个单元格"
Cells(Target.Row, 1).Select
End
End If
If Cells(Target.Row, 1) <> "" And Cells(Target.Row, 2) <> "" And _
Cells(Target.Row, 3) <> "" And Cells(Target.Row, 4) <> "" Then
If Target.Column = 5 Or Target.Column = 6 Or Target.Column = 7 Then
MsgBox "当abcd列不为空时,EFG列不能输入"
Cells(Target.Row, 1).Select
End
Else
End
End If
End If
If Cells(Target.Row, 1) <> "" And Cells(Target.Row, 2) <> "" And _
Cells(Target.Row, 3) <> "" Then
If Target.Column = 5 Or Target.Column = 6 Or Target.Column = 8 Then
MsgBox "当abc列不为空时,EFH列不能输入"
Cells(Target.Row, 1).Select
End
Else
End
End If
End If
If Cells(Target.Row, 1) <> "" And Cells(Target.Row, 2) <> "" Then
If Target.Column = 5 Or Target.Column = 7 Or Target.Column = 8 Then
MsgBox "当ab列不为空时,EGH列不能输入"
End
Else
End
End If
End If
If Cells(Target.Row, 1) <> "" Then
If Target.Column = 6 Or Target.Column = 7 Or Target.Column = 8 Then
MsgBox "当a列不为空时,FGH列不能输入"
Cells(Target.Row, 1).Select
End If
End If
Application.EnableEvents=True
End Sub
|
|