Saturday 24 September 2011

I need to remove items from a list box in Excel, referencing these items by name- not index location. Can I?

I populate a list based on check boxes on a previous page of a dialog box. When someone unchecks a box, i need that part of the list to go away, but I don't want the rest of the entries to be deleted. The list changes all the time, so I can't really reference an index (unless anyone knows some way that I can). Is there any way to delete items by name?I need to remove items from a list box in Excel, referencing these items by name- not index location. Can I?uhm, if i understand what you mean, you are in VBA?



if this is the case, in the code for the checkbox you have your code right now which might look like



if checkbox1 = true then

Range(%26quot;A1%26quot;).formular1c1 = %26quot;this text%26quot;

End if



i dono if thats what you have, just an example.



so then what you can do is under that add this



if Checkbox1 = false then

Range(%26quot;A1%26quot;).clearcontents

end if



this way it will put the info in if it is true, and take it out if it is false.



this code wasnt tested, dont have excel on this computer.



hope it works :)