klpocska Posted March 10, 2010 Posted March 10, 2010 I want to Add ComboBox Items from Blocks attributes with VBA ,but if it is already added to the ComboBox, i dont want to add it again... How to do it? For Each oEnt In oSset [indent]Set oBlkRef = oEnt varAtt = oBlkRef.GetAttributes Set oAtt = varAtt(0) strAtt = oAtt.TextString [/indent] UserForm1.ComboBox1.AddItem strAtt Next oEnt Quote
ollie Posted March 10, 2010 Posted March 10, 2010 For Each oEnt In oSset [indent]Set oBlkRef = oEnt varAtt = oBlkRef.GetAttributes Set oAtt = varAtt(0) strAtt = oAtt.TextString valueAlreadyInList = false For Each item in UserForm1.ComboBox1.items If item = strAtt then valueAlreadyInList = true end if next if !valueAlreadyInList then [/indent] UserForm1.ComboBox1.AddItem strAtt end if Next oEnt You'll need to change 'Userform1.ComboBox1.items' with the appropriate array member but other than that the above should work Similarly if you are sorting the contents once the list has been created you could use a loop to remove duplicates Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.