A Microsoft Office (Excel, Word) forum. OfficeFrustration

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 » OfficeFrustration forum » Microsoft Excel » Setting up and Configuration
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Creating multiple checkboxes in a cell



 
 
Thread Tools Display Modes
  #1  
Old January 26th, 2007, 03:31 PM posted to microsoft.public.excel.setup
Pat
external usenet poster
 
Posts: 677
Default Creating multiple checkboxes in a cell

I want to add 2 checkboxes in one cell, similar to a yes/no checkbox but name
one contract and one permanent so that the person entering the data chooses
either or in that cell in order to identify if an employee is a permanent
employee or not. Can this be done in excel?
--
Thanks, Pat
  #2  
Old January 26th, 2007, 03:54 PM posted to microsoft.public.excel.setup
Dave Peterson
external usenet poster
 
Posts: 19,791
Default Creating multiple checkboxes in a cell

You could do it, but as a user, I wouldn't like it.

I'd want a single checkbox: Permanent?
I could check it for true or uncheck it for false.

I don't want to have to worry about checking both boxes or even leaving both
unchecked and not knowing what that employee was.

If you really want two options, how about a couple of option buttons from the
Forms toolbar surrounded by a groupbox from that same toolbar.

Only one of those optionbuttons can be chosen at a time.

Pat wrote:

I want to add 2 checkboxes in one cell, similar to a yes/no checkbox but name
one contract and one permanent so that the person entering the data chooses
either or in that cell in order to identify if an employee is a permanent
employee or not. Can this be done in excel?
--
Thanks, Pat


--

Dave Peterson
  #3  
Old January 26th, 2007, 05:00 PM posted to microsoft.public.excel.setup
Pat
external usenet poster
 
Posts: 677
Default Creating multiple checkboxes in a cell

If I chose to use a couple of optionbuttons how do I get them into the same
cell.
I do want/need one or the other checked for each entry.
--
Thanks, Pat


"Dave Peterson" wrote:

You could do it, but as a user, I wouldn't like it.

I'd want a single checkbox: Permanent?
I could check it for true or uncheck it for false.

I don't want to have to worry about checking both boxes or even leaving both
unchecked and not knowing what that employee was.

If you really want two options, how about a couple of option buttons from the
Forms toolbar surrounded by a groupbox from that same toolbar.

Only one of those optionbuttons can be chosen at a time.

Pat wrote:

I want to add 2 checkboxes in one cell, similar to a yes/no checkbox but name
one contract and one permanent so that the person entering the data chooses
either or in that cell in order to identify if an employee is a permanent
employee or not. Can this be done in excel?
--
Thanks, Pat


--

Dave Peterson

  #4  
Old January 26th, 2007, 06:27 PM posted to microsoft.public.excel.setup
Dave Peterson
external usenet poster
 
Posts: 19,791
Default Creating multiple checkboxes in a cell

Carefully place them in the cell.

You could also use some code to make life easier (and prettier):

Option Explicit
Sub testme01()

Dim GrpBox As GroupBox
Dim OptBtn As OptionButton
Dim wks As Worksheet
Dim myCell As Range
Dim myRng As Range

Set wks = Worksheets("sheet1")

With wks
'nice for testing
.OptionButtons.Delete
.GroupBoxes.Delete

Set myRng = .Range("a1:A10")
For Each myCell In myRng.Cells
With myCell
Set GrpBox = .Parent.GroupBoxes.Add(Top:=.Top, _
Left:=.Left, _
Width:=.Width, _
Height:=.Height)
GrpBox.Caption = ""
GrpBox.Visible = False

Set OptBtn = .Parent.OptionButtons.Add(Top:=.Top, _
Left:=.Left, _
Width:=.Width / 2, _
Height:=.Height)
OptBtn.Caption = ""
OptBtn.LinkedCell = .Address(external:=True)

Set OptBtn = .Parent.OptionButtons.Add(Top:=.Top, _
Left:=.Left + (.Width / 2), _
Width:=.Width / 2, _
Height:=.Height)
OptBtn.Caption = ""

.NumberFormat = ";;;"

End With
Next myCell
End With
End Sub

It also assigns the linked cell to the cell holding the optionbuttons--but with
a format of ;;;, you don't see it in the worksheet--but you can select the cell
and look at the formulabar to see 1 or 2.

And then you can use:

=countif(a1:a10,1)
=countif(a1:a10,2)
to count the number of each option.

====
It still looks like a checkbox solution to me, though.

Pat wrote:

If I chose to use a couple of optionbuttons how do I get them into the same
cell.
I do want/need one or the other checked for each entry.
--
Thanks, Pat

"Dave Peterson" wrote:

You could do it, but as a user, I wouldn't like it.

I'd want a single checkbox: Permanent?
I could check it for true or uncheck it for false.

I don't want to have to worry about checking both boxes or even leaving both
unchecked and not knowing what that employee was.

If you really want two options, how about a couple of option buttons from the
Forms toolbar surrounded by a groupbox from that same toolbar.

Only one of those optionbuttons can be chosen at a time.

Pat wrote:

I want to add 2 checkboxes in one cell, similar to a yes/no checkbox but name
one contract and one permanent so that the person entering the data chooses
either or in that cell in order to identify if an employee is a permanent
employee or not. Can this be done in excel?
--
Thanks, Pat


--

Dave Peterson


--

Dave Peterson
  #5  
Old January 26th, 2007, 06:36 PM posted to microsoft.public.excel.setup
Pat
external usenet poster
 
Posts: 677
Default Creating multiple checkboxes in a cell

Thank you I will give it a go.
--
Thanks, Pat


"Dave Peterson" wrote:

Carefully place them in the cell.

You could also use some code to make life easier (and prettier):

Option Explicit
Sub testme01()

Dim GrpBox As GroupBox
Dim OptBtn As OptionButton
Dim wks As Worksheet
Dim myCell As Range
Dim myRng As Range

Set wks = Worksheets("sheet1")

With wks
'nice for testing
.OptionButtons.Delete
.GroupBoxes.Delete

Set myRng = .Range("a1:A10")
For Each myCell In myRng.Cells
With myCell
Set GrpBox = .Parent.GroupBoxes.Add(Top:=.Top, _
Left:=.Left, _
Width:=.Width, _
Height:=.Height)
GrpBox.Caption = ""
GrpBox.Visible = False

Set OptBtn = .Parent.OptionButtons.Add(Top:=.Top, _
Left:=.Left, _
Width:=.Width / 2, _
Height:=.Height)
OptBtn.Caption = ""
OptBtn.LinkedCell = .Address(external:=True)

Set OptBtn = .Parent.OptionButtons.Add(Top:=.Top, _
Left:=.Left + (.Width / 2), _
Width:=.Width / 2, _
Height:=.Height)
OptBtn.Caption = ""

.NumberFormat = ";;;"

End With
Next myCell
End With
End Sub

It also assigns the linked cell to the cell holding the optionbuttons--but with
a format of ;;;, you don't see it in the worksheet--but you can select the cell
and look at the formulabar to see 1 or 2.

And then you can use:

=countif(a1:a10,1)
=countif(a1:a10,2)
to count the number of each option.

====
It still looks like a checkbox solution to me, though.

Pat wrote:

If I chose to use a couple of optionbuttons how do I get them into the same
cell.
I do want/need one or the other checked for each entry.
--
Thanks, Pat

"Dave Peterson" wrote:

You could do it, but as a user, I wouldn't like it.

I'd want a single checkbox: Permanent?
I could check it for true or uncheck it for false.

I don't want to have to worry about checking both boxes or even leaving both
unchecked and not knowing what that employee was.

If you really want two options, how about a couple of option buttons from the
Forms toolbar surrounded by a groupbox from that same toolbar.

Only one of those optionbuttons can be chosen at a time.

Pat wrote:

I want to add 2 checkboxes in one cell, similar to a yes/no checkbox but name
one contract and one permanent so that the person entering the data chooses
either or in that cell in order to identify if an employee is a permanent
employee or not. Can this be done in excel?
--
Thanks, Pat

--

Dave Peterson


--

Dave Peterson

 




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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.