+ Reply to Thread
Results 1 to 11 of 11

Listbox Automatic Deselect Bug

  1. #1
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Listbox Automatic Deselect Bug

    I am having a serious problem. I have a listbox tied to a dynamic named range to load values. For some odd reason if there are named ranges it's deselecting any selecting items on calculate. I have no idea why this is happening, but before I completely rebuild my tool, any ideas?

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Listbox Automatic Deselect Bug

    Use VBA's 'dynamic ranges' in listobjects (Tables) or currentregion, or usedrange, or specialcells, or cells(rows.count,1).end(xlup), combined with the listbox property '.List'



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

    Re: Listbox Automatic Deselect Bug

    How have you 'tied' the named range to the listbox?
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Listbox Automatic Deselect Bug

    Quote Originally Posted by Norie View Post
    How have you 'tied' the named range to the listbox?
    Yes Listfillrange: 'DynamicNamedRange'

    It was working for one Listbox, and then as I was coding I found it wasn't working on another. I thought it was my code, and after deconstructing everything 3 times, I found it was the named range. I deleted all listboxes and started from scratch and now only for this workbook. Listfillrange = Named Range will clear selections on recalculate

  5. #5
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Listbox Automatic Deselect Bug

    Quote Originally Posted by snb View Post
    Use VBA's 'dynamic ranges' in listobjects (Tables) or currentregion, or usedrange, or specialcells, or cells(rows.count,1).end(xlup), combined with the listbox property '.List'
    I'm not sure exactly what you're trying to say. Are you listing the possible ways to use a dynamic range?

  6. #6
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Listbox Automatic Deselect Bug

    So, it seems that it is for sure something with the listbox if calculate, then unselect all when linked to DynamicNamed range, not static named range, or static range. This is baffling. I'm new to VBA so maybe there's something I'm missing but this is a royal pain. Solutions?
    Last edited by cmore; 08-31-2013 at 10:16 PM.

  7. #7
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Listbox Automatic Deselect Bug


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

    Re: Listbox Automatic Deselect Bug

    You can used named ranges to populate a listbox, and named ranges can be dynamic.

    You can also not use the ListFillRange property to popuate the listbox, and doing that might prevent the problem you describe.

    For example to populate a listbox from column A on Sheet1:

    Please Login or Register  to view this content.
    This code would go in the worksheet module of the sheet the listbox is on.

  9. #9
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Listbox Automatic Deselect Bug

    Quote Originally Posted by Norie View Post
    This code would go in the worksheet module of the sheet the listbox is on.
    Thanks, I will try this. So the bug is I'm finding an issue of managing the items being unselected on recalculate of the sheet. I have about 8 controls and some require recalculating and it's resetting things in a way I can't find sequence to control

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

    Re: Listbox Automatic Deselect Bug

    The problem is caused by the use of ListFillRange with dynamic named ranges for population of the listboxes.

    Whenever you recalculate the worksheet the dynamic named ranges are recalculated and the listboxes reset.

  11. #11
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Listbox Automatic Deselect Bug

    Dagg, how'd you find this out? I learned this through a lot of pain, but so many moving parts, couldn't determine with certainty. THANK YOU so much man. So ultimately I need to foget the whole named range convention entirely. Problem with the ctrl+down method is my range is housed in a array operation

+ 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. Listbox to Listbox, no duplicates & submitting same UserForm data for each Listbox entry.
    By jamieswift1977 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2012, 12:18 PM
  2. How do I deselect an item from a ListBox
    By skysurfer in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-27-2010, 10:59 AM
  3. [SOLVED] .SeriesCollection(2).Name and .Deselect
    By Peter Sie in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-02-2006, 10:15 PM
  4. [SOLVED] ActiveChart.Deselect won't Deselect
    By Mark Stephens in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-15-2005, 10:05 PM
  5. deselect
    By sali in forum Excel General
    Replies: 2
    Last Post: 04-30-2005, 06:06 PM

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