实施了一个VBA脚本(不是我创建的),可以从输入EXCEL电子表格特定单元格的受控术语列表中选择多个单词。这基于数据验证列表。
问题如下:
任何有关如何更改代码以解决这些问题的建议都将受到高度赞赏!
这是使用的代码:
Option Explicit
' ...
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
Dim lType As Long
Dim strList As String
Application.EnableEvents = False
On Error Resume Next
lType = Target.Validation.Type
On Error GoTo exitHandler
If lType = 3 Then
'if the cell contains a data validation list
Cancel = True
strList = Target.Validation.Formula1
strList = Right(strList, Len(strList) - 1)
strDVList = strList
frmDVList.Show
End If
exitHandler:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
Dim strSep As String
strSep = ", "
Application.EnableEvents = False
On Error Resume Next
If Target.Count > 1 Then GoTo exitHandler
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
newVal = Target.Value
Application.Undo
oldVal = Target.Value
Target.Value = newVal
If newVal = "" Then
'do nothing
Else
If oldVal = "" Then
Target.Value = newVal
Else
Target.Value = oldVal & strSep & newVal
End If
End If
End If
exitHandler:
Application.EnableEvents = True
End Sub
答案 0 :(得分:0)
您提出了多个问题。
这不是您所有问题的完整答案。
我们假设您要将活动限制为仅更改 A 或 B 列。
紧接着:
WHERE System.ItemPathDisplay LIKE '$c' AND CONTAINS('*$word*')
包括如下行:
strSep = ", "
修改此行以限制您感兴趣的列的活动。