Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.setup
Pat Pat is offline
external usenet poster
 
Posts: 210
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   Report Post  
Posted to microsoft.public.excel.setup
external usenet poster
 
Posts: 35,218
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   Report Post  
Posted to microsoft.public.excel.setup
Pat Pat is offline
external usenet poster
 
Posts: 210
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   Report Post  
Posted to microsoft.public.excel.setup
external usenet poster
 
Posts: 35,218
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   Report Post  
Posted to microsoft.public.excel.setup
Pat Pat is offline
external usenet poster
 
Posts: 210
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

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
Display multiple lines of text within a cell from multiple column. Zeeshan Zaheer Excel Worksheet Functions 3 August 23rd 06 10:08 AM
Format cell color based on multiple cell values Zenaida Excel Discussion (Misc queries) 3 May 9th 06 11:56 PM
Multiple Formulas in same cell C Anderson Excel Worksheet Functions 3 April 12th 06 03:31 AM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM
Creating drop down list for multiple cell ranges Aaron Saulisberry Excel Discussion (Misc queries) 2 May 1st 05 06:47 PM


All times are GMT +1. The time now is 12:02 AM.

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"