我目前正在处理一小段代码,可以使我从同一单元格的下拉菜单中选择多个任务。我只是在选择要为其应用此代码的单元格范围,但不能使其与一起使用。范围功能。有人可以看看吗?
请记住我是这个新手:))
这是我的代码:
https://gist.github.com/ciausalo/cb63d2d3e725d11999608ffb0945c36a
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String
Application.EnableEvents = True
On Error GoTo Exitsub
If Target.Range = "$B$2:$H$22" Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
If Oldvalue = "" Then
Target.Value = Newvalue
Else
If InStr(1, Oldvalue, Newvalue) = 0 Then
Target.Value = Oldvalue & ", " & Newvalue
Else:
Target.Value = Oldvalue
End If
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
我期待着听到你的想法。