PDA

View Full Version : Removing Particular value from a Drop Drown form control using VBA



LalitPandey87
10-06-2011, 07:38 AM
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

Excel Fox
10-06-2011, 07:44 AM
Worksheets("Sheet1").DropDowns("NameOfDropDown").RemoveItem 1

LalitPandey87
10-06-2011, 09:54 AM
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.

Excel Fox
10-06-2011, 11:05 AM
Have you changed the sheet name and dropdown name as required?

LalitPandey87
10-06-2011, 11:29 AM
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.

Excel Fox
10-06-2011, 11:42 AM
I have used the same code in the attachment

LalitPandey87
10-06-2011, 11:53 AM
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.:confused:

Excel Fox
10-06-2011, 12:00 PM
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

LalitPandey87
10-06-2011, 01:29 PM
Yup Now its working.....

Thanx