+ Reply to Thread
Results 1 to 6 of 6

populate userform with filtered data

  1. #1
    Registered User
    Join Date
    09-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    9

    populate userform with filtered data

    Hi all, after the very successful last thread im hoping to go one better!

    I have a userform linked to some data - and basically want to show in the userform only the filtered data.

    Normally the attached file has 19 records - however if you filter on colour you get 2 records.

    on the VBA using the aValues = Worksheets("sheet1").Range("dataset").SpecialCells(xlCellTypeVisible) gives a zero value because the 'dataset' when visible starts on row 3 thus doesnt populate the box.

    can anyone help so that the userform just populates the visible filtered data?

    regards Simon
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: populate userform with filtered data

    Simon

    The reason the comboboxes aren't being populated is because you start the loop at 2.

    You could change the 2 to LBound(avalues) but since the array hasn't been populated with all the filtered values it won't work either.

    Try this.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: populate userform with filtered data

    Thanks Norie,
    for some reason when the list isnt filtered - only the first line of the data comes up?
    Also changes have to be made in the sub ABC routine too - which might not be too difficult, but if i apply this against a larger dataset (say with 30 cols of data to be summarised) i am not sure it will be feasible to code?
    Simon

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: populate userform with filtered data

    Simon

    I've just realised a mistake - as well as looping through the Areas we need to loop through the rows in those Areas.

    That's why when there was no filter only the first line showed.

    In fact you would see the problem wherever the results of the filter left contiguous ranges, you would only see the first line.

    Untested but try this.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: populate userform with filtered data

    Norie,

    i think the easiest way to do it was to copy the filtered area to a new page, and direct the userform to populate from that area, once and then clear the data afterwards.

    have attached the spreadsheet working. Thanks for your help though.

    Simon
    Attached Files Attached Files

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: populate userform with filtered data

    That's one way of doing it, and it it works that's the important thing.

    Does the code I posted not work?

+ 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