|
请在填色区域内输入数据验证效果:
- Private Sub Worksheet_Change(ByVal Target As Range)
- Application.ScreenUpdating = False
- If Target.Row > 10 Or Target.Column > 10 Then Exit Sub
- myr = Target.Row
- myc = Target.Column
- If Application.CountA(Range(Cells(1, myc), Cells(10, myc))) > 3 Then
- Target.ClearContents
- MsgBox "该列有数据的单元格已有3个,不能继续输入!"
- Exit Sub
- End If
- If Application.CountA(Range(Cells(myr, 1), Cells(myr, 10))) > 2 Then
- Target.ClearContents
- MsgBox "该列有数据的单元格已有2个,不能继续输入!"
- Exit Sub
- End If
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|