Jump to content

Recommended Posts

Posted

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

Posted


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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...