Solved

List box - only visible entries

Posted on 2012-03-21
4
190 Views
Last Modified: 2012-03-21
Hi,

I have filtered a list for unique entries only, but my code for bring that list into a list box still picks up the hidden rows

Can i change the below code to only import visible entries

Thanks
Seamus

Private Sub UserForm_Activate()

Dim j As String
   
    j = 2
    Do While Sheets("Sheet1").Cells(j, 1).value
        j = j + 1
    Loop
   
    Me.ListBox1.RowSource = "Sheet1!Q2:Q" & (j - 1)



End Sub
0
Comment
Question by:Seamus2626
  • 2
4 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 37746754
0
 
LVL 18

Accepted Solution

by:
p912s earned 500 total points
ID: 37746923
This will get you your unique list without the filter.

Private Sub UserForm_Activate()
    Dim cell As Range
    Dim tempList As Variant: tempList = ""
    For Each cell In Range("Q2:Q" & Range("Q65536").End(xlUp).Row)
        If cell.Value <> "" Then
            If InStr(1, tempList, cell.Value) = 0 Then
                If tempList = "" Then tempList = Trim(CStr(cell.Value)) Else tempList = tempList & "|" & Trim(CStr(cell.Value))
            End If
        End If
    Next cell
    Me.ListBox1.List = Split(tempList, "|")
End Sub

Open in new window

0
 

Author Closing Comment

by:Seamus2626
ID: 37746939
Cheers, thats the one i needed!

Seamus
0
 
LVL 18

Expert Comment

by:p912s
ID: 37746988
Glad to help!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question