您当前的位置: 首页 > 办公软件教程 > Excel教程 浏览
vba与数据有效性的例子
发布时间:2015-10-25    点击率:次    来源:www.sytcke.com    作者:电脑技术学习网

   If Target.Count > 2 Then Exit Sub

  If Target.Column <> 3 Or Target.Row <3 Then Exit Sub

  Dim aa, Arr, i&

  Target.Offset(0, -1) = ""

  Arr = Sheet1.[a1].CurrentRegion

  For i = 3 To UBound(Arr)

  If Arr(i, 2) = Target.Value Then

  aa = aa & Arr(i, 1) & ","

  End If

  Next

  If aa = "" Then MsgBox "没有找到编号": Exit Sub

  aa = Left(aa, Len(aa) - 1)

  With Target.Offset(0, -1).Validation

  .Delete

  .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _

  Operator:=xlBetween, Formula1:=aa

  End With

发表留言
发表留言请先登录!
免责声明:本站发布的信息和评论纯属网民个人行为,并不代表本站立场,如发现有违法信息或侵权行为,请直接与本站管理员联系,我们将在收到您的信息后24小时内作出处理!