Results 1 to 5 of 5

code to deselect if empty record is clicked in listbox

Threaded View

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

    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:

    Private Sub lstBox1_Click()
    Dim i As Integer
    i = Me.lstBox1.ListIndex
    If (Me.lstBox1.Column(1, i) = "") Then 'i.e. empty record
        Me.lstBox1.Selected(i) = False
    Else
        Me.lstBox1.Selected(i) = True
    End If
    End Sub
    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.

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