View Single Post
 
Old 06-12-2019, 11:13 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

At its simplest you would just add items to the combobox e.g.

Code:
Private Sub UserForm_Initialize()
    With ComboBox1
        .AddItem "Select an Item"
        .AddItem "This is the first item"
        .AddItem "This is the second item"
        .AddItem "This is the third item"
        .ListIndex = 0
    End With
End Sub
or you could use an array e.g.
Code:
Private Sub UserForm_Initialize()
Dim vList As Variant
    vList = Array("Select an Item", "This is the first item", "This is the second item", "This is the third item")
    With ComboBox1
        .List = vList
        .ListIndex = 0
    End With
End Sub
or a combination of the two e.g.
Code:
Private Sub UserForm_Initialize()
Dim vList(3) As Variant
    vList(0) = "Select an Item"
    vList(1) = "This is the first item"
    vList(2) = "This is the second item"
    vList(3) = "This is the third item"

    With ComboBox1
        .List = vList
        .ListIndex = 0
    End With
End Sub
You would populate the appropriate part of the document, ideally using a content control, with the value from the combobox.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote