返回列表 上一主題 發帖

VBA 抓取ListBox中的內容

回復 59# wang077

請測試看看,謝謝

Private Sub CommandButton5_Click()
Dim ar2, s%
s = 0: ReDim ar2(s)
With Sheets("總表").Range("a2:u" & [a65536].End(3).Row)
    Sheets(1).AutoFilterMode = False
    For i = 0 To ListBox2.ListCount - 1
        If ListBox2.Selected(i) = True Then
            ReDim Preserve ar2(s)
            ar2(s) = CStr(ListBox2.List(i))
            s = s + 1
        End If
    Next
    .AutoFilter Field:=7, Criteria1:=ar2, Operator:=xlFilterValues
End With
Set ar2 = Nothing
End Sub

TOP

回復 61# samwang
測試過了,沒問題,謝謝大大

TOP

        靜思自在 : 一個人不怕錯,就怕不改過,改過並不難。
返回列表 上一主題