Solved

List box - only visible entries

Posted on 2012-03-21
4
189 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

777 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