+ Reply to Thread
Results 1 to 5 of 5

Fill listbox after autofilter has been applied

Hybrid View

  1. #1
    Registered User
    Join Date
    04-25-2006
    Posts
    25

    Fill listbox after autofilter has been applied

    Hi there,

    I'm looking for some code that would allow me to fill a listbox on a userform with the resulting columdata (column D) after the columns to the left have been autofiltered.

    Anyone who could be of assistance, please ?

    Thanks in advance
    Eric

  2. #2
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Are you applying the autofilter in the code of your form? If so, use something like

     for each c in intersect([d:d], activesheet.usedrange)
        listbox1.additem c.value
    next
    If that's not clear attach the spreadhseet and I'll be more explixit.


    HTH
    Col
    Last edited by VBA Noob; 05-21-2007 at 05:02 PM.
    If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.

  3. #3
    Registered User
    Join Date
    04-25-2006
    Posts
    25
    Thanks, however when I apply the code the header of the column is included (which it should not) and the listbox includes all values in the column, while only the visibles in d:d after the autofilter has been applied (in column a,b and c) should be shown. And yes, the autofilter is applied in the code of the form.

    Regards - Eric

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Eric

    Slight mod to the previous code

    For Each ce In Intersect(Range("D2:D" & Cells(Rows.Count, 1).End(xlUp).Row), Range("D:D").SpecialCells(xlCellTypeVisible))
        listbox1.AddItem ce.Value
      Next ce

    rylo

  5. #5
    Registered User
    Join Date
    04-25-2006
    Posts
    25
    Many thanks indeed, works now as intendend !

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1