Allentw821
New Member
- Joined
- Nov 23, 2017
- Messages
- 4
Hello,
I have a power query table on sheet2 that will have a different range each time the query is ran. I need it to populate a list box on sheet1. Kicker. It also has to be able to populate with filtered data also (filter selection is a combo box on Sheet1 "C26"). I tried a few different ways as shown on previous questions from other users. No success. Thank you.
I have a power query table on sheet2 that will have a different range each time the query is ran. I need it to populate a list box on sheet1. Kicker. It also has to be able to populate with filtered data also (filter selection is a combo box on Sheet1 "C26"). I tried a few different ways as shown on previous questions from other users. No success. Thank you.
Code:
Private Sub ComboBox1_Change()
If Range("Sheet1!C26") = "All Areas"Then
Application.Sheets("Sheet2").ListObjects("Files").Range.AutoFilter
Else
Application.Sheets("Sheet2").ListObjects("Files").Range.AutoFilterField:=3, Criteria1:=Range("Sheet1!C26")
End If
With Sheets("Sheet2")
Dim LR As Long
Dim rng As Range
LR =Cells(Rows.Count, "A").End(xlUp).Row
Set rng =Sheets("Sheet2").Range("A1:A" &LR).SpecialCells(xlCellTypeVisible)
End With
With Sheet1.ListBox1
.ListFillRange =(this code is what I need)
.ListIndex = 0
.Activate
End With
End Sub
Last edited by a moderator: