Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Excel VBA Populatig UserFrom Contols as Design Time.

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Excel VBA Populatig UserFrom Contols as Design Time.

Hi FSt1,
Thanks for the prompt response.
Unfotunately I didn't explain myself well.
What I meant to say was that I want to populate the ComboBox Value at Design
Time not the ComboBox RowSource.

It is intended that sometimes the value will be populated from its dropdown
and other times from a value in another ComboBox.
--
Regards
John Howard
Sydney, Australia


"FSt1" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Excel VBA Populatig UserFrom Contols as Design Time.

Sub test()
Dim arrList
Dim u As UserForm
Dim cbo As ComboBox

arrList = Array("Line 111", "Line 222", "Line 333")
Set u = ThisWorkbook.VBProject.VBComponents("UserForm1").D esigner
Set cbo = u.ComboBox1
cbo.List = arrList

End Sub

You'll need to Trust access to VB Project in your security settings. FWIW
you can design an entire Userform from scratch with the Designer object.

Regards,
Peter T

"John Howard" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Resizing of picture different in run time and design time Broadband-Al[_2_] Excel Programming 3 September 26th 09 07:29 PM
I need a basic quick time line design clt64 Excel Discussion (Misc queries) 1 February 14th 08 07:46 PM
The design of this website sucks big time linzhang426 New Users to Excel 5 October 9th 05 12:43 PM
Design time events Josh Sale Excel Programming 2 December 3rd 04 07:39 PM
Userfrom code in written in Excel 2000 running in Excel 97 KimberlyC Excel Programming 1 February 11th 04 08:45 PM


All times are GMT +1. The time now is 09:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"