[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

List box - only visible entries

Posted on 2012-03-21
4
Medium Priority
?
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 37746754
0
 
LVL 18

Accepted Solution

by:
p912s earned 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

649 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