+ Reply to Thread
Results 1 to 5 of 5

Remove Item in a combobox

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    883

    Remove Item in a combobox

    Hi All

    I have bulit a userform in which there is one combobox that stores the values present in a column in excel sheet. Now my problem is when I process one item ,I want to remove that item from a combobox although it is present in excel sheet.

    How to remove the selected item in a combobox..Could anyone please provide me vba code for this

    Regards
    Aman

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Remove Item in a combobox

    Hello aman124,

    Welcome to the Forum!

    You can remove an item from a ComboBox provided it is not linked to a range. To remove the item, you must get the ListIndex value of the selected item. This index value is used with the RemoveItem method.

    Remove the First Entry of the ComboBox
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    883

    Re: Remove Item in a combobox

    Hi

    How can i find Listindex value of the selected item..thats is my problem ..i tried various methods but they don't work e.g

    1. ComboBox1.RemoveItem ComboBox1.ListIndex
    2. Private Sub cmdDelete_Click()
    'For I = 0 To ComboBox1.ListCount - 1

    'If ComboBox1.ListIndex(I) = Val(ComboBox1.Text) Then
    ' ComboBox1.RemoveItem (ComboBox1.ListIndex)

    'Exit For
    'End If
    'Next

    can you please helpme..
    Regards
    Aman

    3. ComboBox1.RemoveItem (ComboBox1.ListIndex)

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Remove Item in a combobox

    Hello aman1234,

    It would help to see the code you have written or a sample workbook. I can then give you a specific answer to this problem.

  5. #5
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    883

    Re: Remove Item in a combobox

    Hi Leith

    Could be please see my thread "Problem in comparing dates". As last time u solved my problem very quickly.Could you please try to solve this problem too.

    Regards
    Aman
    Quote Originally Posted by Leith Ross View Post
    Hello aman1234,

    It would help to see the code you have written or a sample workbook. I can then give you a specific answer to this problem.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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