another listbox question

  • Thread starter Thread starter john.9.williams
  • Start date Start date
J

john.9.williams

hi all, following on from another question, is it possible to display
data that is filtered within a list box, i only want certain data to
appear in this list the list is automatically filtered, but the whole
list still appears in the list box.

regards john
 
Private Sub UserForm_Activate()
Dim rng As Range, rng1 As Range
Dim cell As Range
Dim i As Long
ListBox1.Clear
ListBox1.ColumnCount = 4
Set rng = Range("a2:a50")
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
For Each cell In rng1
ListBox1.AddItem cell.Value
i = ListBox1.ListCount - 1
ListBox1.List(i, 1) = cell.Offset(0, 1)
ListBox1.List(i, 2) = cell.Offset(0, 2)
ListBox1.List(i, 3) = cell.Offset(0, 3)
Next
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top