LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default checkbox in Excel form

Hi Sam,

I would do it like this.

First place all the checkboxes into a frame. You can set the properties of
this so it doesn't show to the user.

Then use the code below in the click event of the submit button.

Private Sub Command_Submit_Click()
Dim ctl As Control
Dim mytext As String
Dim ctrl As Control
Dim SumValue As Integer

'initialise variables
SumValue = 0
mytext = ""

'check that a box is ticked
For Each ctrl In Frame1.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
SumValue = SumValue + ctrl.Value
End If
Next
If SumValue = 0 Then 'no checkboxes ticked
MsgBox "You haven't ticked any boxes!"
Exit Sub
End If

'combine captions
For Each ctrl In Frame1.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
If ctrl.Value = True Then
Select Case mytext
Case ""
mytext = ctrl.Caption
Case Else
mytext = mytext & ", " & ctrl.Caption
End Select
End If
End If
Next
'populate whatever cell you want.
ActiveSheet.Range("A1") = mytext
End Sub




"sam" wrote:

Hi All,

I have 6 checkboxes on an excel user form, Selecting each checkbox will
display the checkbox value on the excel sheet, If user selects more then one
checkbox I want to populate the excel sheet with all the selected values
like, Value1, Value2 Etc.. (All the checkboxes represent the same field)
For eg:

Select people you know from the list:
[] John
[] Jill
[] Jack
[] Bill
[] Josh
[] Bob

So if a user selects John, Jill and Josh. I want the cell to display John,
Jill, Josh.

What I also want is for users to select atleast one checkbox, if they dont
select any checkbox and click submit i want excel to diaplay a message.

How do I do this?

Please Help!

Thanks in Advance

 
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
How do I setup a cell in Excel as a checkbox w/o a form/activex c. Arno Rite Excel Discussion (Misc queries) 15 November 27th 06 08:50 PM
How do I make a checkbox bigger in an excel form? tscyw8 Excel Discussion (Misc queries) 0 February 7th 06 10:22 PM
how to delete or remove checkbox form control in Excel? tubbekans Excel Discussion (Misc queries) 1 December 14th 05 08:51 PM
checkbox on form reset from checkbox on sheet raw[_12_] Excel Programming 1 December 3rd 05 05:08 AM
add size option to excel form checkbox TG Excel Discussion (Misc queries) 0 April 28th 05 09:20 PM


All times are GMT +1. The time now is 07:35 AM.

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

About Us

"It's about Microsoft Excel"