Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 06-12-2019, 11:13 PM
gmayor's Avatar
gmayor gmayor is offline UserForm with Combo Box from data in table within template Windows 10 UserForm with Combo Box from data in table within template 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
 

Tags
combo box, user forms



Similar Threads
Thread Thread Starter Forum Replies Last Post
Letter Template /w combo box list etruz Word 4 10-31-2018 05:16 AM
Copy excel userform data to a word template Farnkf1970 Excel Programming 1 10-31-2017 01:35 AM
Pasting a table with combo boxes to a new document looses the combo box bobsut@enviro-consult.com Word 1 01-03-2017 01:29 PM
userform to enter multiple lines of data in template callasabra Word VBA 0 06-27-2014 05:29 PM
Forms - Combo Box Linking data tomkat Word 1 04-23-2010 06:28 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft