如何用vba编写数据有效性语句

您所在的位置:网站首页 vba设置数据有效性怎么设置出来 如何用vba编写数据有效性语句

如何用vba编写数据有效性语句

2024-07-15 11:33| 来源: 网络整理| 查看: 265

QUOTE:以下是引用lautumn在2009-12-19 12:22:00的发言:

请问怎么用字典呢?

结合搁浅学委和我师傅的代码给你写了一个字典的,去掉重复的数据

Sub test()    Dim Col As Integer    Dim Str As String    Dim dic As Object    Dim i As Integer    Dim arr    Set dic = CreateObject("scripting.dictionary")    Col = [IV1].End(xlToLeft).Column    arr = Range(Cells(1, 1), Cells(1, Col))    For i = 1 To Col        If Not dic.exists(arr(1, i)) Then            dic(arr(1, i)) = 1        End If    Next    [A65536].Resize(1, dic.Count) = dic.keys    Str = "=" & Range("A65536", Cells(65536, [IV65536].End(xlToLeft).Column)).Address    Stop    With [B2].Validation        .Delete        .Add Type:=xlValidateList, Formula1:=Str    End WithEnd Sub

[此贴子已经被作者于2009-12-19 14:27:44编辑过]


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3