Re: [VBA ] Excel下拉式清單-多選的小問題
把 .ListFillRange = "A1:A5" 換成下面那行
.ListFillRange = Range("A1", Range("A1").End(xlDown)).Address
把A欄全部填到ListBox
※ 引述《nonaidsman (My Love)》之銘言:
: 可以請教各位前輩
: 正在學習怎麼在Excel內打上下拉多選清單,利用listbox
: 但參考網路上的語言可以成功實現,如下
: Private Sub ListBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
: Shift As Integer)
: Dim arr(), s%, i%
: If KeyCode = 13 Then
: For i = 0 To ListBox1.ListCount - 1
: If ListBox1.Selected(i) = True Then
: ReDim Preserve arr(s)
: arr(s) = ListBox1.List(i)
: s = s + 1
: End If
: Next
: [B1] = Join(arr, ",")
: ListBox1.Visible = False
: End If
: End Sub
: Private Sub Worksheet_SelectionChange(ByVal Target As Range)
: With ListBox1
: If Target.Address = "$B$1" Then
: .Top = Range("B1").Top + Range("B1").Height
: .Left = Range("B1").Left
: .ListFillRange = "A1:A5"
: .MultiSelect = fmMultiSelectMulti
: .Visible = True
: Else
: ListBox1.Visible = False
: End If
: End With
: End Sub
: ------------------------------------------------------
: 但後來我需要是一整欄(例如B欄)都可以套用到這各下拉選單
: 請問我該怎麼修改這各語言阿,先跟各位前輩感謝了!
: 試了好多次,查了好久都沒辦法解決@@
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.141.53.109
討論串 (同標題文章)