1、首先设置对应单元格的下拉选项。
2、点击sheet名,查看代码
3、然后根据自己要求,复制对应代码。
---整个sheet的内容都可以多选
Option Explicit
Sub Worksheet_Change(ByVal Target As Range)
'整个sheet的内容都可以多选
Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
If Target.Count > 1 Then GoTo exitHandler
On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
Application.EnableEvents = False
newVal = Target.Value
Application.Undo
oldVal = Target.Value
Target.Value = newVal
If oldVal = "" Then
Else
If newVal = "" Then