Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
HFB HFB is offline
external usenet poster
 
Posts: 17
Default how to write vb code for multiple combo boxes

I have several combo boxes with names: drill1, drill2, drill3 etc. I want to
write code that gives a Yes option and a No option in each of those boxes
without having to write code for each one. Is there a way to do this?

thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how to write vb code for multiple combo boxes

Will these boxes only contain Yes and No? If so, why not just use a
checkbox?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
I have several combo boxes with names: drill1, drill2, drill3 etc. I want

to
write code that gives a Yes option and a No option in each of those boxes
without having to write code for each one. Is there a way to do this?

thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
HFB HFB is offline
external usenet poster
 
Posts: 17
Default how to write vb code for multiple combo boxes

Yeah, they will only contain yes and no. I don't actually have enough space
in the form to do check boxes.

"Bob Phillips" wrote:

Will these boxes only contain Yes and No? If so, why not just use a
checkbox?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
I have several combo boxes with names: drill1, drill2, drill3 etc. I want

to
write code that gives a Yes option and a No option in each of those boxes
without having to write code for each one. Is there a way to do this?

thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default how to write vb code for multiple combo boxes

HFB,

If you must create them as ComboBoxes and not CheckBoxes (not sure why
CheckBoxes would be any bigger), here's a way:

Dim ctl As Control

For Each ctl In Controls
If TypeOf ctl Is MSForms.ComboBox Then
If ctl.Name Like "drill*" Then
ctl.Object.AddItem "Yes"
ctl.Object.AddItem "No"
End If
End If
Next ctl

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


HFB wrote:
Yeah, they will only contain yes and no. I don't actually have
enough space in the form to do check boxes.

"Bob Phillips" wrote:

Will these boxes only contain Yes and No? If so, why not just use a
checkbox?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
I have several combo boxes with names: drill1, drill2, drill3 etc.
I want to write code that gives a Yes option and a No option in
each of those boxes without having to write code for each one. Is
there a way to do this?

thanks


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how to write vb code for multiple combo boxes

Because a checkbox only has two states, you can use one checkbox for yes and
no, same number of controls.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
Yeah, they will only contain yes and no. I don't actually have enough

space
in the form to do check boxes.

"Bob Phillips" wrote:

Will these boxes only contain Yes and No? If so, why not just use a
checkbox?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
I have several combo boxes with names: drill1, drill2, drill3 etc. I

want
to
write code that gives a Yes option and a No option in each of those

boxes
without having to write code for each one. Is there a way to do this?

thanks








  #6   Report Post  
Posted to microsoft.public.excel.programming
HFB HFB is offline
external usenet poster
 
Posts: 17
Default how to write vb code for multiple combo boxes

Assuming I copy it into the code exactly the way you've written it there - it
doesn't work...
(I'm obviously not proficient in this...)

"Jake Marx" wrote:

HFB,

If you must create them as ComboBoxes and not CheckBoxes (not sure why
CheckBoxes would be any bigger), here's a way:

Dim ctl As Control

For Each ctl In Controls
If TypeOf ctl Is MSForms.ComboBox Then
If ctl.Name Like "drill*" Then
ctl.Object.AddItem "Yes"
ctl.Object.AddItem "No"
End If
End If
Next ctl

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


HFB wrote:
Yeah, they will only contain yes and no. I don't actually have
enough space in the form to do check boxes.

"Bob Phillips" wrote:

Will these boxes only contain Yes and No? If so, why not just use a
checkbox?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
I have several combo boxes with names: drill1, drill2, drill3 etc.
I want to write code that gives a Yes option and a No option in
each of those boxes without having to write code for each one. Is
there a way to do this?

thanks



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default how to write vb code for multiple combo boxes

I would have thought a check means yes, seems the logical value to me. It's
what you get all the time in Excel, for instance ToolsOptionsGeneral, and
the Gridlines checkbox, I have always assumed that to me yes I want
Gridlines.

--
HTH

Bob Phillips

"HFB" wrote in message
...
Okay. How does the user know what the check means? Or do I go with the
theory that a check means yes and no check means no?

"Bob Phillips" wrote:

Because a checkbox only has two states, you can use one checkbox for yes

and
no, same number of controls.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
Yeah, they will only contain yes and no. I don't actually have enough

space
in the form to do check boxes.

"Bob Phillips" wrote:

Will these boxes only contain Yes and No? If so, why not just use a
checkbox?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
I have several combo boxes with names: drill1, drill2, drill3 etc.

I
want
to
write code that gives a Yes option and a No option in each of

those
boxes
without having to write code for each one. Is there a way to do

this?

thanks








  #8   Report Post  
Posted to microsoft.public.excel.programming
HFB HFB is offline
external usenet poster
 
Posts: 17
Default how to write vb code for multiple combo boxes

Okay, I'll go with that thanks.

Now for part two. Same situation, BUT there are about 15 options on the
list. I have 12 combo boxes that each need to display the 15 options. I
know how to do the code for each individual one, but not for all in one hit.
I tried Jake's 'ctl' code thing and it didn't seem to work - I prolly did
something wrong...

"Bob Phillips" wrote:

I would have thought a check means yes, seems the logical value to me. It's
what you get all the time in Excel, for instance ToolsOptionsGeneral, and
the Gridlines checkbox, I have always assumed that to me yes I want
Gridlines.

--
HTH

Bob Phillips

"HFB" wrote in message
...
Okay. How does the user know what the check means? Or do I go with the
theory that a check means yes and no check means no?

"Bob Phillips" wrote:

Because a checkbox only has two states, you can use one checkbox for yes

and
no, same number of controls.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
Yeah, they will only contain yes and no. I don't actually have enough
space
in the form to do check boxes.

"Bob Phillips" wrote:

Will these boxes only contain Yes and No? If so, why not just use a
checkbox?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
I have several combo boxes with names: drill1, drill2, drill3 etc.

I
want
to
write code that gives a Yes option and a No option in each of

those
boxes
without having to write code for each one. Is there a way to do

this?

thanks









  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default how to write vb code for multiple combo boxes

Make one list: in a worksheet, say range A1:A15
Give you list a Name, Say MyList
In each of your 12 comboboxes type in the MyList in the ListFillRange or
Input range.

"HFB" wrote:

Okay, I'll go with that thanks.

Now for part two. Same situation, BUT there are about 15 options on the
list. I have 12 combo boxes that each need to display the 15 options. I
know how to do the code for each individual one, but not for all in one hit.
I tried Jake's 'ctl' code thing and it didn't seem to work - I prolly did
something wrong...

"Bob Phillips" wrote:

I would have thought a check means yes, seems the logical value to me. It's
what you get all the time in Excel, for instance ToolsOptionsGeneral, and
the Gridlines checkbox, I have always assumed that to me yes I want
Gridlines.

--
HTH

Bob Phillips

"HFB" wrote in message
...
Okay. How does the user know what the check means? Or do I go with the
theory that a check means yes and no check means no?

"Bob Phillips" wrote:

Because a checkbox only has two states, you can use one checkbox for yes

and
no, same number of controls.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
Yeah, they will only contain yes and no. I don't actually have enough
space
in the form to do check boxes.

"Bob Phillips" wrote:

Will these boxes only contain Yes and No? If so, why not just use a
checkbox?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
I have several combo boxes with names: drill1, drill2, drill3 etc.

I
want
to
write code that gives a Yes option and a No option in each of

those
boxes
without having to write code for each one. Is there a way to do

this?

thanks









  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how to write vb code for multiple combo boxes

Gocush gave you one way, but if you want to do it from code, Jake's answer
can be simplified somewhat, as there is only one combo, so need to loop
through

With ActiveSheet.OLEObjects("ComboBox1").Object
.Clear
.AddItem "Bob"
.AddItem "Lynne"
.AddItem "Amy"
.AddItem "Hannah"
.AddItem "Sita"
.ListIndex = 0
End With

Change the name to suit.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
Okay, I'll go with that thanks.

Now for part two. Same situation, BUT there are about 15 options on the
list. I have 12 combo boxes that each need to display the 15 options. I
know how to do the code for each individual one, but not for all in one

hit.
I tried Jake's 'ctl' code thing and it didn't seem to work - I prolly did
something wrong...

"Bob Phillips" wrote:

I would have thought a check means yes, seems the logical value to me.

It's
what you get all the time in Excel, for instance ToolsOptionsGeneral,

and
the Gridlines checkbox, I have always assumed that to me yes I want
Gridlines.

--
HTH

Bob Phillips

"HFB" wrote in message
...
Okay. How does the user know what the check means? Or do I go with

the
theory that a check means yes and no check means no?

"Bob Phillips" wrote:

Because a checkbox only has two states, you can use one checkbox for

yes
and
no, same number of controls.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
Yeah, they will only contain yes and no. I don't actually have

enough
space
in the form to do check boxes.

"Bob Phillips" wrote:

Will these boxes only contain Yes and No? If so, why not just

use a
checkbox?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
I have several combo boxes with names: drill1, drill2, drill3

etc.
I
want
to
write code that gives a Yes option and a No option in each of

those
boxes
without having to write code for each one. Is there a way to

do
this?

thanks













  #11   Report Post  
Posted to microsoft.public.excel.programming
HFB HFB is offline
external usenet poster
 
Posts: 17
Default how to write vb code for multiple combo boxes

Jake - assuming I enter the code in as written - this does not work. No
errors or anything, but not values in the combo boxes either. Is some of
what you've written supposed to be replaced with something else according to
my requirements?

thank

"Jake Marx" wrote:

HFB,

If you must create them as ComboBoxes and not CheckBoxes (not sure why
CheckBoxes would be any bigger), here's a way:

Dim ctl As Control

For Each ctl In Controls
If TypeOf ctl Is MSForms.ComboBox Then
If ctl.Name Like "drill*" Then
ctl.Object.AddItem "Yes"
ctl.Object.AddItem "No"
End If
End If
Next ctl

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


HFB wrote:
Yeah, they will only contain yes and no. I don't actually have
enough space in the form to do check boxes.

"Bob Phillips" wrote:

Will these boxes only contain Yes and No? If so, why not just use a
checkbox?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
I have several combo boxes with names: drill1, drill2, drill3 etc.
I want to write code that gives a Yes option and a No option in
each of those boxes without having to write code for each one. Is
there a way to do this?

thanks



  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default how to write vb code for multiple combo boxes

I wrote this to work with ComboBoxes on a UserForm. If you have them on a
Worksheet, the syntax will be slightly different:

Dim ctl As OLEObject

For Each ctl In OLEObjects
If TypeOf ctl.Object Is MSForms.ComboBox Then
If ctl.Name Like "drill*" Then
ctl.Object.AddItem "Yes"
ctl.Object.AddItem "No"
End If
End If
Next ctl

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


HFB wrote:
Jake - assuming I enter the code in as written - this does not work.
No errors or anything, but not values in the combo boxes either. Is
some of what you've written supposed to be replaced with something
else according to my requirements?

thank

"Jake Marx" wrote:

HFB,

If you must create them as ComboBoxes and not CheckBoxes (not sure
why CheckBoxes would be any bigger), here's a way:

Dim ctl As Control

For Each ctl In Controls
If TypeOf ctl Is MSForms.ComboBox Then
If ctl.Name Like "drill*" Then
ctl.Object.AddItem "Yes"
ctl.Object.AddItem "No"
End If
End If
Next ctl

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


HFB wrote:
Yeah, they will only contain yes and no. I don't actually have
enough space in the form to do check boxes.

"Bob Phillips" wrote:

Will these boxes only contain Yes and No? If so, why not just use a
checkbox?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"HFB" wrote in message
...
I have several combo boxes with names: drill1, drill2, drill3 etc.
I want to write code that gives a Yes option and a No option in
each of those boxes without having to write code for each one. Is
there a way to do this?

thanks


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
Getting Combo boxes to change options based on other Combo boxes. Ancient Wolf New Users to Excel 1 March 27th 09 06:29 PM
multiple combo boxes jeff Excel Discussion (Misc queries) 2 December 16th 08 05:02 PM
Multiple combo boxes with unique duplicates showing only Nemo New Users to Excel 0 July 6th 07 03:20 PM
multiple combo boxes LilyDog7 Excel Discussion (Misc queries) 4 October 17th 05 10:22 PM
Adding the same content to multiple combo boxes keaven Excel Programming 3 June 11th 04 02:34 PM


All times are GMT +1. The time now is 06:44 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"