【技巧1001-10】-下拉列表居然可以多选?!

请看效果图:



如何制作:

1、常规下拉列表制作

2、粘贴VBA代码

'作者:Excel办公实战-小易
'日期:2019-8-12
'功能:下拉框多选
'******************************************************
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count <> 1 Then End
'Columns(3)-这里的3表示下拉列表所在的列(C列)
If Intersect(Target, Columns(3)).Cells.Count = 0 Then End
Application.EnableEvents = False
newdata = Target.Value
Application.Undo
olddata = Target.Value
If newdata <> "" Then
If olddata <> "" Then
Target.Value = olddata & "," & newdata
If InStr(olddata, newdata) > 0 Then
Target.Value = olddata
Else
Target.Value = olddata & "," & newdata
End If
Else
Target = newdata
End If
End If
Application.EnableEvents = True
End Sub
赞 (0)