A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Microsoft Word Help
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Looping UserForm ComboBox



 
 
Thread Tools Display Modes
  #1  
Old June 6th 10, 09:36 AM posted to microsoft.public.word.docmanagement
owen
external usenet poster
 
Posts: 61
Default Looping UserForm ComboBox

Hi

I would like to use the code below in a loop so that i can populate numerous
ComboBoxes within my UserForm with the same list.

I am not sure how to go about this, and would appreciate any help.

Thanks

With ComboBox7
Dim MonthArray As Variant
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
ComboBox7.List = MonthArray
End With
Ads
  #2  
Old June 6th 10, 10:22 AM posted to microsoft.public.word.docmanagement
Graham Mayor
external usenet poster
 
Posts: 19,312
Default Looping UserForm ComboBox

Something like:

Option Explicit
Private MonthArray As Variant
Private Sub UserForm_Initialize()
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
Me.ComboBox1.list = MonthArray
Me.ComboBox2.list = MonthArray
Me.ComboBox3.list = MonthArray
Me.ComboBox4.list = MonthArray
Me.ComboBox5.list = MonthArray
End Sub

will do the job

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"Owen" wrote in message
...
Hi

I would like to use the code below in a loop so that i can populate
numerous
ComboBoxes within my UserForm with the same list.

I am not sure how to go about this, and would appreciate any help.

Thanks

With ComboBox7
Dim MonthArray As Variant
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
ComboBox7.List = MonthArray
End With



  #3  
Old June 6th 10, 10:22 AM posted to microsoft.public.word.docmanagement
Graham Mayor
external usenet poster
 
Posts: 19,312
Default Looping UserForm ComboBox


Something like:

Option Explicit
Private MonthArray As Variant
Private Sub UserForm_Initialize()
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
Me.ComboBox1.list = MonthArray
Me.ComboBox2.list = MonthArray
Me.ComboBox3.list = MonthArray
Me.ComboBox4.list = MonthArray
Me.ComboBox5.list = MonthArray
End Sub

will do the job

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"Owen" wrote in message
...
Hi

I would like to use the code below in a loop so that i can populate
numerous
ComboBoxes within my UserForm with the same list.

I am not sure how to go about this, and would appreciate any help.

Thanks

With ComboBox7
Dim MonthArray As Variant
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
ComboBox7.List = MonthArray
End With



  #4  
Old June 6th 10, 12:59 PM posted to microsoft.public.word.docmanagement
owen
external usenet poster
 
Posts: 61
Default Looping UserForm ComboBox

Thanks Graham...it did the trick.

"Graham Mayor" wrote:

Something like:

Option Explicit
Private MonthArray As Variant
Private Sub UserForm_Initialize()
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
Me.ComboBox1.list = MonthArray
Me.ComboBox2.list = MonthArray
Me.ComboBox3.list = MonthArray
Me.ComboBox4.list = MonthArray
Me.ComboBox5.list = MonthArray
End Sub

will do the job

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"Owen" wrote in message
...
Hi

I would like to use the code below in a loop so that i can populate
numerous
ComboBoxes within my UserForm with the same list.

I am not sure how to go about this, and would appreciate any help.

Thanks

With ComboBox7
Dim MonthArray As Variant
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
ComboBox7.List = MonthArray
End With



.

  #5  
Old June 6th 10, 12:59 PM posted to microsoft.public.word.docmanagement
owen
external usenet poster
 
Posts: 61
Default Looping UserForm ComboBox


Thanks Graham...it did the trick.

"Graham Mayor" wrote:

Something like:

Option Explicit
Private MonthArray As Variant
Private Sub UserForm_Initialize()
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
Me.ComboBox1.list = MonthArray
Me.ComboBox2.list = MonthArray
Me.ComboBox3.list = MonthArray
Me.ComboBox4.list = MonthArray
Me.ComboBox5.list = MonthArray
End Sub

will do the job

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"Owen" wrote in message
...
Hi

I would like to use the code below in a loop so that i can populate
numerous
ComboBoxes within my UserForm with the same list.

I am not sure how to go about this, and would appreciate any help.

Thanks

With ComboBox7
Dim MonthArray As Variant
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
ComboBox7.List = MonthArray
End With



.

  #6  
Old June 6th 10, 01:25 PM posted to microsoft.public.word.docmanagement
Graham Mayor
external usenet poster
 
Posts: 19,312
Default Looping UserForm ComboBox

You are welcome

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"Owen" wrote in message
...
Thanks Graham...it did the trick.

"Graham Mayor" wrote:

Something like:

Option Explicit
Private MonthArray As Variant
Private Sub UserForm_Initialize()
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
Me.ComboBox1.list = MonthArray
Me.ComboBox2.list = MonthArray
Me.ComboBox3.list = MonthArray
Me.ComboBox4.list = MonthArray
Me.ComboBox5.list = MonthArray
End Sub

will do the job

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"Owen" wrote in message
...
Hi

I would like to use the code below in a loop so that i can populate
numerous
ComboBoxes within my UserForm with the same list.

I am not sure how to go about this, and would appreciate any help.

Thanks

With ComboBox7
Dim MonthArray As Variant
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
ComboBox7.List = MonthArray
End With



.



  #7  
Old June 6th 10, 01:25 PM posted to microsoft.public.word.docmanagement
Graham Mayor
external usenet poster
 
Posts: 19,312
Default Looping UserForm ComboBox


You are welcome

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"Owen" wrote in message
...
Thanks Graham...it did the trick.

"Graham Mayor" wrote:

Something like:

Option Explicit
Private MonthArray As Variant
Private Sub UserForm_Initialize()
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
Me.ComboBox1.list = MonthArray
Me.ComboBox2.list = MonthArray
Me.ComboBox3.list = MonthArray
Me.ComboBox4.list = MonthArray
Me.ComboBox5.list = MonthArray
End Sub

will do the job

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"Owen" wrote in message
...
Hi

I would like to use the code below in a loop so that i can populate
numerous
ComboBoxes within my UserForm with the same list.

I am not sure how to go about this, and would appreciate any help.

Thanks

With ComboBox7
Dim MonthArray As Variant
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
ComboBox7.List = MonthArray
End With



.



  #8  
Old June 6th 10, 02:33 PM posted to microsoft.public.word.docmanagement
Greg_Maxey via OfficeKB.com
external usenet poster
 
Posts: 1
Default Looping UserForm ComboBox

Graham's answer is will do the job quite well in this case. There are a few
other techniques that you might put in your toolbox for cases where the
number of controls involved is large:

The first loops through like named controls with an index number:

Private MonthArray As Variant
Private Sub UserForm_Initialize()
Dim i As Long
Dim CtrNameArray As String
CtrNameArray = Split("ComboBox1|ComboBox1|ComboBox1|ComboBox1|Com boBox1")
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
For i = 1 To 5 'or to whatever number you need.
Me.Controls("ComboBox" & i).List = MonthArray
Next i
End Sub

The other uses a second array to provide uniquely named controls to the loop:

Private Sub UserForm_Initialize()
Dim i As Long
Dim CtrNameArray() As String 'Variant
CtrNameArray = Split
("ComboBoxAlpha|ComboBoxBravo|ComboBoxCharlie|Comb oBoxDelta|ComboBoxEcho",
"|")
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
For i = 0 To UBound(CtrNameArray)
Me.Controls(CtrNameArray(i)).List = MonthArray
Next i
End Sub



Owen wrote:
Hi

I would like to use the code below in a loop so that i can populate numerous
ComboBoxes within my UserForm with the same list.

I am not sure how to go about this, and would appreciate any help.

Thanks

With ComboBox7
Dim MonthArray As Variant
MonthArray = Split("01|02|03|04|05|06|07|08|09|10|11|12|", "|")
ComboBox7.List = MonthArray
End With


--
Greg Maxey

Please visit my web site http://gregmaxey.mvps.org

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...ement/201006/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Enable a ComboBox using VBA TonyK Microsoft Word Help 1 July 6th 09 03:23 PM
Mail Merge looping through records ram Mailmerge 2 June 6th 09 11:34 AM
Looping Macro for Selection String Between Quotation Marks RPMitchal Microsoft Word Help 7 August 5th 08 11:40 PM
ComboBox Help Kenny Microsoft Word Help 1 September 22nd 07 01:32 AM
combobox Gman1959 Microsoft Word Help 1 January 28th 05 12:16 AM


All times are GMT +1. The time now is 10:27 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2004-2019 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.