+ Reply to Thread
Results 1 to 5 of 5

code to deselect if empty record is clicked in listbox

  1. #1
    Registered User
    Join Date
    06-02-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    75

    code to deselect if empty record is clicked in listbox

    I have a little tool to populate and filter data, the data gets manipulated through a list box.

    When I click on a record in the list box, the record gets highlighted, which is fine. However, occasionally, I could also click on empty rows specially when I have less number of data records after I filter them. I need to disable/ deselect when I click on empty record.

    I have this code in the list box click event, but it does not work for the purpose:

    Please Login or Register  to view this content.
    Any idea why it is not working? . I am also attaching an excel file in the following link:
    https://www.dropbox.com/s/aw36c56n2z...s_LT.xlsm?dl=0

    I appreciate any help .. Thanks
    Last edited by adelkam; 02-26-2015 at 12:10 AM.

  2. #2
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: code to deselect if empty record is clicked in listbox

    when I deleted the Row in the Range to test the code.
    the List box doesn't iterated the itself as desired. I guess, there is a problem with the code iterating the Listbox.

    Check the attached file:-
    Attached Files Attached Files
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  3. #3
    Registered User
    Join Date
    06-02-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: code to deselect if empty record is clicked in listbox

    Hi Vikas_Gautam

    I do not see any thing has changed. To illustrate, please do the following steps:

    - Let the userform starts.
    - CLick on "project" radio button
    - CLick on an empty area in the list box right below the last record... a blank record gets highlighted !!!

    I need to prevent this... It still allowing a blank record to get clicked and highlighted.. Thanks
    Last edited by adelkam; 02-26-2015 at 01:23 AM.

  4. #4
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: code to deselect if empty record is clicked in listbox

    Problem is solved.

    I choose plan B. that is , to redefine the Listbox RowSource using Filtered date each time filter is used. For this purpose I have used an extra Sub "RefreshListBox"

    Check the attached file:-
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-02-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: code to deselect if empty record is clicked in listbox

    Thank you very much Vikas_Gautam for your help

    This works perfect! .. you made myday

    All the best!!

+ 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] if anything in listbox select first item, if listbox empty do nothing (listbox in userform
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2015, 12:49 PM
  2. Code to find matching record in listbox on sheet.
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-01-2014, 04:07 AM
  3. [SOLVED] Listbox Automatic Deselect Bug
    By cmore in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-05-2013, 07:36 PM
  4. 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
  5. Help! How to record time a hyperlink was clicked?
    By yoggit in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-13-2005, 11:17 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