Hello,
In a worksheet I have a list with different kinds or records (errors, warnings, etc). I also have a userform that can show these. What I want to accomplish is that I can use a optionbutton to filter 1 type of record and show that in that listbox of my userform. See attached.
I am able to show all data in the listbox. And I am also able to filter the data in the table. However, I cannot get only the filtered data in the listbox.
Private Sub OptionErrors_Click()
Dim wsw As Worksheet
Set wsw = Worksheets("Warnings")
wsw.Range("ErrMsg_Filter").Value = "Err"
Dim i As Integer ' row in Warning ws
i = 5 ' first row
Dim LastRow As Long
LastRow = wsw.Range("A" & Rows.Count).End(xlUp).Row ' Last row in Warnings ws
If LastRow < 5 Then LastRow = 5
Dim lo As ListObject
Set lo = wsw.ListObjects(1)
lo.AutoFilter.ShowAllData
With lo.Range
.AutoFilter Field:=6, Criteria1:="E"
End With
Dim rngWarnings As Range
Set rngWarnings = lo.DataBodyRange.Columns("B:F")
With Me.ListBox1
.ColumnWidths = "30;50;325;450"
.ColumnCount = -1
.List = rngWarnings.Cells.Value
End With
End Sub
Bookmarks