Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 4 of 4

Thread: Remove Listbox Item

  1. #1
    Join Date
    10th July 2007
    Posts
    11

    Remove Listbox Item

    I have a list box and I input data into it.
    I have a delete button that removes items from the list box

    I am trying to tell it not to remove anything and display a msgbox when nothing is selected from the list box. But then if something is selected delete that one and only that one.


    HELP!!!!!

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    22nd January 2004
    Location
    Colorado Springs
    Posts
    3,992

    Re: Remove Item Listbox

    What kind of listbox are you using ( Forms or Control Toolbox )?

    If you're using the "Forms" type then you are making a list on a worksheet so simply remove the item from the list.

    If you're using the "Control Toolbox" type then you are using "AddItem" to input new items into a list box. So you can use "RemoveItem" along with the index of the selected item to remove a selected item.
    Regards,
    Barry

    My Favorite New Thing:
    Dynamic Named Ranges



    The alternative for
    "Press Any Key To Continue."

    and we all have one we'd like to use it on


    1. Cross Posting Etiquette
    2. Are You Here To Learn: What Have You Tried?
    3. Your Best Resource to begin learning VBA: RECORD A MACRO . . . Then Study It!

  3. #3
    Join Date
    10th July 2007
    Posts
    11

    Re: Remove Item Listbox

    I got it

    VB:
    Private Sub CommandButton2_Click() 
         
        If UserForm8.ListBox1.Value = ListBox1 Then 
            UserForm8.ListBox1.RemoveItem (UserForm8.ListBox1.ListIndex) 
            UserForm8.TextBox6.Locked = False 
        Else 
            MsgBox "Please select a name to be Removed from this list", vbOKOnly + vbCritical, "ERROR" 
        End If 
        If UserForm8.ListBox1.ListCount = 0 Then 
            UserForm8.ListBox1.Visible = False 
            UserForm8.CommandButton2.Visible = False 
        End If 
         
    End Sub 
    
    
    Last edited by Dave Hawley; July 20th, 2007 at 12:35.

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    10th July 2007
    Posts
    11

    Re: Remove Item Listbox

    I got it

    VB:
    Private Sub CommandButton2_Click() 
         
        If UserForm8.ListBox1.Value = ListBox1 Then 
            UserForm8.ListBox1.RemoveItem (UserForm8.ListBox1.ListIndex) 
            UserForm8.TextBox6.Locked = False 
        Else 
            MsgBox "Please select a name to be Removed from this list", vbOKOnly + vbCritical, "ERROR" 
        End If 
        If UserForm8.ListBox1.ListCount = 0 Then 
            UserForm8.ListBox1.Visible = False 
            UserForm8.CommandButton2.Visible = False 
        End If 
         
    End Sub 
    
    
    Last edited by Dave Hawley; July 20th, 2007 at 12:35.

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. De-Select ListBox Item
    By The Dutchman in forum EXCEL HELP
    Replies: 3
    Last Post: June 19th, 2008, 04:24
  2. Remove Item From RowSource & Listbox
    By abbyyjai in forum EXCEL HELP
    Replies: 7
    Last Post: January 22nd, 2008, 19:37
  3. Remove Item From Multiple Select Listbox
    By jstevens in forum EXCEL HELP
    Replies: 1
    Last Post: June 2nd, 2007, 01:35
  4. see the last item on userform listbox
    By DROM in forum EXCEL HELP
    Replies: 4
    Last Post: February 2nd, 2006, 23:09
  5. selecting item in listbox...
    By mjschukas in forum EXCEL HELP
    Replies: 2
    Last Post: October 11th, 2004, 00:27

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
  •  
porno