Macro to add drop down values

D

Dave Legg

I want to be able to add items dynamically to a drop down depending on what item was selected in the previous one

I need full code

David Legg
 
D

Doug Robbins - Word MVP

Hi Dave,

The following is a procedure that is based on the items in the first
dropdown being stored one per row in the first column of a table and the
items for the second dropdown that correspond to the items in the first
dropdown, being stored in the adjacent cell, one per paragraph.

Dim sourcedoc As Document, i As Long, myitem As Range
' Modify the path in the following line so that it matches where you saved
Suppliers.doc
Set sourcedoc = Documents.Open(FileName:="d:\worddocs\Suppliers.doc")
For i = 1 To sourcedoc.Tables(1).Cell(Company.ListIndex + 2,
2).Range.Paragraphs.Count
Set myitem = sourcedoc.Tables(1).Cell(Company.ListIndex + 2,
2).Range.Paragraphs(i).Range
myitem.End = myitem.End - 1
SalesRep.ADDITEM myitem.Text
Next i
sourcedoc.Close SaveChanges:=wdDoNotSaveChanges

Note This code is for use with comboboxes on a userform.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
I want to be able to add items dynamically to a drop down depending on what
item was selected in the previous one

I need full code

David Legg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top