underpressure
Board Regular
- Joined
- Nov 24, 2012
- Messages
- 141
I’m attempting to display only the Active Members in my database (Sheet11).
This code populates ListBox1 with the entire database Range (C2:C).
How can I modify the code to show only the Filtered Range?
This code populates ListBox1 with the entire database Range (C2:C).
How can I modify the code to show only the Filtered Range?
Code:
Private Sub CommandButton4_Click()
If CommandButton4.Caption = "View Active Roster" Then
Sheet11.Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$FY$267").AutoFilter Field:=14, Criteria1:="A"
With Sheet11
ListBox1.List = .Range("C2", .Range("C" & .Rows.Count).End(xlUp)).Resize(, 1).Value
End With
ListBox1.Visible = True
Label1.Visible = True
CommandButton4.Caption = "Close Active Roster"
Label1.Caption = Sheet11.[C1].Value
Else
ListBox1.Visible = False
CommandButton4.Caption = "View Active Roster"
Label1.Visible = False
Selection.AutoFilter
End If
End Sub