我插入了以下代码,这样我就可以从数据验证列表中为单个单元格C14、D14和E14选择多行。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String
On Error GoTo Exitsub
Target.Address = "$C$14" Or Target.Address = "$D$14" Or Target.Address = "$E$14" 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
Target.Value = Oldvalue & ", " & Newvalue
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub
对不起,没有问题。连接应如何使Newvalue出现在下一行而不是同一行。我想代码需要在这里发一些推特Target.Value = Oldvalue & ", " & Newvalue
谢谢你的提示。
更改代码如下:-
Target.Value = Oldvalue & vbNewLine & Newvalue