ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting in a userform (https://www.excelbanter.com/excel-programming/315461-counting-userform.html)

dan

Counting in a userform
 
I have 10 combo boxes in a userform frame. I would like
the user to select just ONE combo box. If any more than 2
are select, and before my ActiveCell.Offset updates the
spreadsheet. I would like to catch this multiple input
error and send msgbox then Cancel=true back to the
userform for correction.

My 10 combo's are as follows:
cboA.Value
..
..
cboJ.Value
I thought that I could loop and count, if count great than
1, stop and message, return and correct. My code locked me
up. Thanks.

dan

Counting in a userform
 
Can this be accomplished by setting up as an array?

-----Original Message-----
I have 10 combo boxes in a userform frame. I would like
the user to select just ONE combo box. If any more than 2
are select, and before my ActiveCell.Offset updates the
spreadsheet. I would like to catch this multiple input
error and send msgbox then Cancel=true back to the
userform for correction.

My 10 combo's are as follows:
cboA.Value
..
..
cboJ.Value
I thought that I could loop and count, if count great

than
1, stop and message, return and correct. My code locked

me
up. Thanks.
.


Bob Phillips[_6_]

Counting in a userform
 
Dan,

Count them and output the msgbox from within the form. If not more than one,
then exit.

This si some code for running from an OK type button.

'-----------------------------------------------------------------
Private Sub Commandbutton1_Click()
'-----------------------------------------------------------------
Dim ctl As msforms.Control
Dim iCbs As Long

For Each ctl In Me.Controls
If TypeName(ctl) = "ComboBox" Then
If ctl.ListIndex < -1 Then
i=i+1
If i 1 Then
MsgBox "Only select one"
Exit Sub
End If
End If
End If
Next ctl

Me.Hide

End Sub


--

HTH

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


"Dan" wrote in message
...
I have 10 combo boxes in a userform frame. I would like
the user to select just ONE combo box. If any more than 2
are select, and before my ActiveCell.Offset updates the
spreadsheet. I would like to catch this multiple input
error and send msgbox then Cancel=true back to the
userform for correction.

My 10 combo's are as follows:
cboA.Value
.
.
cboJ.Value
I thought that I could loop and count, if count great than
1, stop and message, return and correct. My code locked me
up. Thanks.




dan

Counting in a userform
 
Bob, I am a newbie as if you can't tell! Do I have to
replace the Me and the "Combo box"? Because when I run I
get a compile error:wrong # of arguments or invalid
property asignment. Thanks Dan
-----Original Message-----
Dan,

Count them and output the msgbox from within the form. If

not more than one,
then exit.

This si some code for running from an OK type button.

'---------------------------------------------------------

--------
Private Sub Commandbutton1_Click()
'---------------------------------------------------------

--------
Dim ctl As msforms.Control
Dim iCbs As Long

For Each ctl In Me.Controls
If TypeName(ctl) = "ComboBox" Then
If ctl.ListIndex < -1 Then
i=i+1
If i 1 Then
MsgBox "Only select one"
Exit Sub
End If
End If
End If
Next ctl

Me.Hide

End Sub


--

HTH

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


"Dan" wrote in

message
...
I have 10 combo boxes in a userform frame. I would like
the user to select just ONE combo box. If any more than

2
are select, and before my ActiveCell.Offset updates the
spreadsheet. I would like to catch this multiple input
error and send msgbox then Cancel=true back to the
userform for correction.

My 10 combo's are as follows:
cboA.Value
.
.
cboJ.Value
I thought that I could loop and count, if count great

than
1, stop and message, return and correct. My code locked

me
up. Thanks.



.


dan

Counting in a userform
 
I made an error, go figure. Corrected and works great
Thanks, Dan
-----Original Message-----
Bob, I am a newbie as if you can't tell! Do I have to
replace the Me and the "Combo box"? Because when I run I
get a compile error:wrong # of arguments or invalid
property asignment. Thanks Dan
-----Original Message-----
Dan,

Count them and output the msgbox from within the form.

If
not more than one,
then exit.

This si some code for running from an OK type button.

'--------------------------------------------------------

-
--------
Private Sub Commandbutton1_Click()
'--------------------------------------------------------

-
--------
Dim ctl As msforms.Control
Dim iCbs As Long

For Each ctl In Me.Controls
If TypeName(ctl) = "ComboBox" Then
If ctl.ListIndex < -1 Then
i=i+1
If i 1 Then
MsgBox "Only select one"
Exit Sub
End If
End If
End If
Next ctl

Me.Hide

End Sub


--

HTH

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


"Dan" wrote in

message
...
I have 10 combo boxes in a userform frame. I would like
the user to select just ONE combo box. If any more

than
2
are select, and before my ActiveCell.Offset updates the
spreadsheet. I would like to catch this multiple input
error and send msgbox then Cancel=true back to the
userform for correction.

My 10 combo's are as follows:
cboA.Value
.
.
cboJ.Value
I thought that I could loop and count, if count great

than
1, stop and message, return and correct. My code

locked
me
up. Thanks.



.

.


Bob Phillips[_6_]

Counting in a userform
 
I'm glad about that, as I had no further advice<vbg

Bob

"Dan" wrote in message
...
I made an error, go figure. Corrected and works great
Thanks, Dan
-----Original Message-----
Bob, I am a newbie as if you can't tell! Do I have to
replace the Me and the "Combo box"? Because when I run I
get a compile error:wrong # of arguments or invalid
property asignment. Thanks Dan
-----Original Message-----
Dan,

Count them and output the msgbox from within the form.

If
not more than one,
then exit.

This si some code for running from an OK type button.

'--------------------------------------------------------

-
--------
Private Sub Commandbutton1_Click()
'--------------------------------------------------------

-
--------
Dim ctl As msforms.Control
Dim iCbs As Long

For Each ctl In Me.Controls
If TypeName(ctl) = "ComboBox" Then
If ctl.ListIndex < -1 Then
i=i+1
If i 1 Then
MsgBox "Only select one"
Exit Sub
End If
End If
End If
Next ctl

Me.Hide

End Sub


--

HTH

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


"Dan" wrote in

message
...
I have 10 combo boxes in a userform frame. I would like
the user to select just ONE combo box. If any more

than
2
are select, and before my ActiveCell.Offset updates the
spreadsheet. I would like to catch this multiple input
error and send msgbox then Cancel=true back to the
userform for correction.

My 10 combo's are as follows:
cboA.Value
.
.
cboJ.Value
I thought that I could loop and count, if count great

than
1, stop and message, return and correct. My code

locked
me
up. Thanks.


.

.





All times are GMT +1. The time now is 05:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com