返回列表 上一主題 發帖

[發問] 重複資料,如何使用VBA方式,指定特定字串製作成清單(已解決)

回復 5# totes
不須使用範圍作清單
  1. Sub ex()
  2. Set d = CreateObject("Scripting.Dictionary")
  3. C = InputBox("輸入開頭字元", , "TC")
  4. ar = Range("E2", [E65536].End(xlUp)).Value
  5. For Each a In ar
  6.   If a Like C & "*" Then d(a) = ""  '不重複符合規則
  7. Next
  8. If d.Count = 0 Then MsgBox "無符合資料": Exit Sub
  9. With Range("G11").Validation
  10. .Delete
  11. .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
  12.         xlBetween, Formula1:=Join(d.keys, ",")
  13.         .IgnoreBlank = True
  14.         .InCellDropdown = True
  15.         .InputTitle = ""
  16.         .ErrorTitle = ""
  17.         .InputMessage = ""
  18.         .ErrorMessage = ""
  19.         .IMEMode = xlIMEModeNoControl
  20.         .ShowInput = True
  21.         .ShowError = True
  22. End With
  23. End Sub
複製代碼
學海無涯_不恥下問

TOP

        靜思自在 : 能善用時間的人,必能掌握自己努力的方向。
返回列表 上一主題