+ Reply to Thread
Results 1 to 7 of 7

Listbox non-updating/updating

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-04-2003
    Posts
    360

    Listbox non-updating/updating

    I would like to be able to change the way a listbox functions from allowing input, to not allowing input (but still being able to view previous selections).

    I understand .enabled will achieve this but if it is set to false then the i am unable to scroll the list.

    Any ideas/solutions?

    tia Matt.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    What kind of ListBox? On a UserForm, from the Forms ToolBar or Controls ToolBox?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    12-04-2003
    Posts
    360
    It's from the controls toolbox - the lists are placed directly on the worksheet.

    (also, is there anyway of getting rid of the notice at the topas I've already read it - like an accept notice button or something along those lines?)

    ta.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    The notice is only temporary. It should go in a couple of days.

    What input are you referring to, you cxan't type directly into a ListBox.

  5. #5
    Forum Contributor
    Join Date
    12-04-2003
    Posts
    360
    normal listbox input - i.e. clicking an item in the listbox.

    I've already created the listbox and populated it.
    I want to hold the input so a user can use the current selection. (effectively non-updatable - but scrollable)
    Then I want to 'switch modes' to updatable. (i.e. select more or less items (Updatable))

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I'm not sure what you can do, you could try changing the Locked property, but how will you trigger any such change?

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,449
    Maybe this would work for you.

    Userform with a listbox, commandbutton and label.
    Click button to toggle 'lock' listbox selection.

    You can select items when unlocked.
    You can scroll list whether locked or not.

    Private m_blnLocked As Boolean
    Private m_vntSelected() As Variant
    Private m_lngListIndex As Long
    
    Private Sub CommandButton1_Click()
    
        m_blnLocked = Not m_blnLocked
        Label1.Caption = m_blnLocked
        
    End Sub
    
    Private Sub ListBox1_Change()
    
        If m_blnLocked Then
            m_lngListIndex = ListBox1.ListIndex
            ListBox1.Selected(ListBox1.ListIndex) = m_vntSelected(ListBox1.ListIndex)
        Else
            m_lngListIndex = ListBox1.ListIndex
            If ListBox1.ListIndex >= 0 Then
                m_vntSelected(ListBox1.ListIndex) = ListBox1.Selected(ListBox1.ListIndex)
            End If
        End If
        
    End Sub
    
    Private Sub UserForm_Initialize()
    
        ListBox1.List = Array(1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9)
        ListBox1.MultiSelect = fmMultiSelectMulti
        
        ReDim m_vntSelected(0 To ListBox1.ListCount - 1)
        m_blnLocked = False
        m_lngListIndex = -1
        
    End Sub
    Cheers
    Andy
    www.andypope.info

+ 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. Excel 2007 : MouseWheel on Listbox Crashes my Excel 2007
    By ShredDude in forum Excel General
    Replies: 3
    Last Post: 05-09-2008, 01:19 AM
  2. Problem in Returning Values from a Multi-column Listbox (ActiveX)
    By shivboy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-16-2007, 02:51 PM
  3. Listbox - multiselectmulti properties
    By marcospaterson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-09-2007, 09:53 AM
  4. Insert a listbox in a sheet
    By Jilt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-06-2007, 06:28 PM
  5. Removing items using listbox
    By Mr.Jones in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 01-12-2007, 07:57 AM

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