+ Reply to Thread
Results 1 to 7 of 7

VBA Excel - List box only populating one result

  1. #1
    Registered User
    Join Date
    01-17-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    4

    VBA Excel - List box only populating one result

    I dont usually add requests on here, but after trawling everywhere, I can't seem to find an answer and this really baffling me!

    I have a form that is populating data from a seperate spreadsheet which connects to a sharepoint site using a web query.

    My script filters the data and returns the results into a listbox.

    Everything seems to work fine, but when I filter two fields it will only return a single result and not the list of data. I have stepped through the code and it is filtering correctly, just not displaying the results.

    The most confusing thing is I have the exact same code with only one filter on a different page of the form that returns the data correctly.

    The working code is:

    Please Login or Register  to view this content.
    This returns the full list in my listbox 'ActiveListBox', however the below code will only return the first result:

    Please Login or Register  to view this content.
    I'm really stuck with this and would really appreciate any help!!!

    Thanks Paul

  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: VBA Excel - List box only populating one result

    Have you checked what rngVis2 is?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    01-17-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: VBA Excel - List box only populating one result

    I've tried to populate this to a msgbox before setting it as the value of the Listbox, but I got a debug error

  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: VBA Excel - List box only populating one result

    Use rngVis2.Address to see the address.

  5. #5
    Registered User
    Join Date
    01-17-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: VBA Excel - List box only populating one result

    Thanks.

    It contains multiple rows of data, so it does appear to be capturing it correctly, just not transferring it to the listbox,

    yet with one filter it does???

  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: VBA Excel - List box only populating one result

    If the ranges are non-contiguous then the listbox will only be populated with the first area.

    What you could do is loop through all the areas and their ranges.

    Something like this perhaps.
    Please Login or Register  to view this content.
    Not ideal but will work.

    An alternative would be to copy rngVis to a worksheet and populate the listbox from there.

  7. #7
    Registered User
    Join Date
    01-17-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: VBA Excel - List box only populating one result

    That's great,

    I can't try it untill monday when I return to work, but I understand the logic behind it and should be fine now!

    I will most like copy the data prior to importing to the listbox!

    Thanks for your help!

    Paul

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Populating excel cells depending on what is chosen from a drop down list
    By seanzerd in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-19-2013, 05:39 AM
  2. Replies: 2
    Last Post: 06-05-2013, 10:45 PM
  3. List box not populating in Excel 2013
    By belakeresearch in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-14-2013, 03:38 PM
  4. Populating cells with the result of a drop down list
    By Barking_Mad in forum Excel General
    Replies: 7
    Last Post: 09-20-2009, 02:58 AM
  5. Populating list in excel from VB Form
    By bhagwat in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2009, 07:03 AM

Tags for this Thread

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