0
我有以下代碼,允許我在數據驗證下選擇多個項目。不過,我有兩個組數據進行驗證,並且我只希望這個代碼應用的範圍(「K41:K60,K73:K107)請告知感謝VBA適用於特定範圍
Private Sub Worksheet_Change(ByVal Target As Range)
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
Else
Application.EnableEvents = False
newVal = Target.Value
Application.Undo
oldVal = Target.Value
Target.Value = newVal
If oldVal = "" Then
Else
If newVal = "" Then
Else
Target.Value = oldVal _
& ", " & newVal
End If
End If
End If
exitHandler:
Application.EnableEvents = True
End Sub
您好,感謝答覆。我已經第二個下拉列表中的H3,但我不希望它能夠選擇上面代碼中的多個項目 – CaL
如果您的代碼可以避免H3選擇列表中的多個項目,那麼我應該在哪裏插入代碼?我是新來的宏或編碼,我在網上找到代碼。謝謝! – CaL
對不起,我不確定我關注。你能解釋一些關於你在做什麼嗎? – SJR