Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. . . |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
counting function but not double counting duplicates | Excel Worksheet Functions | |||
Counting rows, then counting values. | Excel Discussion (Misc queries) | |||
Counting names in a column but counting duplicate names once | Excel Discussion (Misc queries) | |||
Linking userform to userform in Excel 2003 | Excel Programming | |||
Userform inside another userform | Excel Programming |