【发布时间】:2018-04-26 11:24:33
【问题描述】:
对于我遇到的问题,我将不胜感激。以下代码示例允许我从下拉列表中选择多个值,但是我需要 target.address 是列 S 中的每一行。
我不确定如何更改目标地址,使其成为从 s10 开始的范围(即 S10-S150)
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String
On Error GoTo Exitsub
If Target.Address = "$S10" 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
谢谢!
【问题讨论】: