Dim Filter As String
Dim str As String =""
Static lst As List(of Date) '定义一个静态集合变量,用于存储选择的日期
If lst Is Nothing Then
lst = New List(of Date)
End If
If ModifierKey <> Keys.Control Then '如果没有按下Ctrl键
lst.Clear() '清除以前的日期
End If
If lst.Contains(e.Sender.Value) = False Then '如果集合不包括按下的日期
lst.Add(e.Sender.Value) '则向集合添加此日期
End If
For Each nm As Date In lst
str &= format(nm,"yyyy-MM-dd") & ","
Next
str = str.Trim(",")
Filter = "第一列 In ('" & str.Replace(",", "','") & "')"
msgbox(Filter )
Tables("表A").Filter = Filter