View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default Excel VBA Populatig UserFrom Contols as Design Time.

hi
2 basic ways to do that.
set the rowsource or use the add item method.
this would more that likely be used in the userform initilazation.
assuming you have a list on a sheet somewhere.
Private Sub UserForm_Initialize()
Me.ComboBox1.ListFillRange = ""
Me.ComboBox1.ListFillRange = "A1:A12"
end sub

or the add item method
Dim r As Range
Set r = Sheets("sheet1").Range("A1:A12")
me.ComboBox1.Clear
For Each c In r
me.ComboBox1.AddItem c.Value
Next c

above code is untested by should work.

Regards
FSt1

"John Howard" wrote:

UserFrom1.ComboBox1 = "John Howard"

The above code populates the control ComboBox1 with the string John Howard.
This is just a Runtime with the ComboBox not retaining the string.
What is the syntes for populating the control ComboBox at Design Time so
that the string is retained even after closing and reopening/
--
Regards
John Howard
Sydney, Australia