Results 1 to 9 of 9

Thread: Removing Particular value from a Drop Drown form control using VBA

  1. #1
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    14

    Removing Particular value from a Drop Drown form control using VBA

    Hi,

    I need a code which removes a particular value from the Drop Down (Form Control) using VBA.
    Actually the condition is when the Drop Drown fill first time there is a value which is "Select Value" in the first
    position
    Whenever a user select any value from the Drop Down then this value should be Removed so the user can not select this
    value again.
    And after removing this value the index should be Reindex.

    It will a great help for me

    Thanx in Advance.
    :o
    Last edited by LalitPandey87; 10-06-2011 at 07:41 AM.

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Code:
    Worksheets("Sheet1").DropDowns("NameOfDropDown").RemoveItem 1
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  3. #3
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    14
    Thanx for giving me ur time from ur busy schedule.

    I applied this but its not working for me. I don't know what i am doing wrong.

  4. #4
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Have you changed the sheet name and dropdown name as required?
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  5. #5
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    14
    Yaa,

    but it gives some error. and this command which you wrote is for Form Control(does'nt mean that i am creating user forms i placed the control in a sheet)
    I really need it

    Thanx.

  6. #6
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    I have used the same code in the attachment
    Attached Files Attached Files
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  7. #7
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    14
    Its Gives me

    Run-Time Error '1004'
    RemoveItem method of DropDown class failed

    Error when i am writing the same in my excel file.

    I am filling this List Box by a namedrange.

  8. #8
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    You cannot have the listfill range and expect to remove an item from the list!! Instead of having the listfill through a range, why don't you add each item. Then you will also be able to remove item
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  9. #9
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    14
    Yup Now its working.....

    Thanx

Similar Threads

  1. Replies: 1
    Last Post: 05-03-2013, 04:41 PM
  2. Removing unused Cell styles - need an efficient code
    By siddharthsindhwani in forum Excel Help
    Replies: 8
    Last Post: 04-15-2013, 07:12 AM
  3. Creating drop-down function in excel
    By Jorrg1 in forum Excel Help
    Replies: 4
    Last Post: 01-09-2013, 01:45 PM
  4. ScrollBar Not Aligned In MultiPage Form VBA
    By Tony in forum Excel Help
    Replies: 1
    Last Post: 10-31-2012, 11:43 PM
  5. Animation on Form Control
    By Mechanic in forum Excel Help
    Replies: 4
    Last Post: 03-22-2011, 08:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •