- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 107
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2025-5-4
               
|
5#
發表於 2010-5-11 22:53
| 只看該作者
本帖最後由 Hsieh 於 2010-5-11 23:03 編輯
回復 4# letugo
這樣可能要用到VBA輔助才行
Dropdown list.rar (14.06 KB)
- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim Ar()
- Set d = CreateObject("Scripting.Dictionary")
- If Target.Column = 3 Then '指定欄位
- With Target.EntireColumn.Validation
- .Delete
- For Each a In Range(Cells(2, Target.Column), Target)
- d(a.Value) = d(a.Value) + 1
- Next
- Do Until d.Count = 0 Or i = 20
- k = Application.Large(d.items, 1)
- k = Application.Match(k, d.items, 0)
- ans = Application.Index(d.keys, k)
- If mystr = "" Then
- mystr = ans
- Else
- mystr = mystr & "," & ans
- End If
- d.Remove ans: i = i + 1
- Loop
- If Not IsError(mystr) And mystr <> "" Then .Add xlValidateList, Formula1:=mystr: .ShowError = False
- End With
- End If
- End Sub
複製代碼 |
|