How do I make tjek-boxes?

  • Thread starter Thread starter Lars Christoffersen
  • Start date Start date
L

Lars Christoffersen

Hi All

I'm looking for a way to use a field to make a tjek-box (sort of the thing
in a questionnaire)

Can anyone guide me through that in an easy way, because the help file
didn't help a lot.......?

It's in Excel 2000

Regards

/LC
 
Checkboxes in English?

Do you want them on a worksheet?

If yes to both:

There are two different types of checkboxes. One is on the Forms toolbar and
one is on the Control Toolbox Toolbar.

You can see these toolbars via View|Toolbars|and checking each.

You click on the checkbox and then "draw a box" where you want it to go on the
worksheet.

===
But before you go too far, are you sure you don't want to use Optionbuttons.

Checkboxes are square and you can choose as many as you want.
Optionbuttons are round and you can only choose one per group.

If your survey is a simple yes/no question and you have one checkbox per
question (yes=checked, no=not checked), then checkboxes make sense to me.

If your survey allows for (say) 5 responses, but only one response per question,
then Optionbuttons make more sense to me. (The option buttons have to be
grouped some way so that all the optionbuttons on the sheet aren't seen as one
set of responses.)

=====
I'm gonna guess that you want OptionButtons.

And since I like the optionbuttons from the forms toolbar (I find them easier to
work with), I'd use something like this macro to put a few sets of optionbuttons
on a worksheet.

I put 5 buttons (maxBtns=5) in each group. I started each group in column C
(actually C4:C9).

I have a linked cell (to tell me which one of the group was selected). It's in
column B of that same row--but I hid it with a numberformat of ";;;" (w/o the
quotes). (I just commented that line in the code. I figured if you want to
hide them you can either uncomment the line or even hide the whole column.)

(You can even hide the groupbox by setting the .visible property to False--it's
a line in the code.)

And the code removes all the optionbuttons and all the groupboxes (it makes
testing easier).


Option Explicit
Sub testme01()

Dim grpBox As GroupBox
Dim optBtn As OptionButton
Dim maxBtns As Long
Dim myCell As Range
Dim myRange As Range
Dim wks As Worksheet
Dim iCtr As Long

maxBtns = 5

Set wks = ActiveSheet
With wks
Set myRange = .Range("c4:c9")
myRange.EntireRow.RowHeight = 28
myRange.Resize(, maxBtns).EntireColumn.ColumnWidth = 4
.GroupBoxes.Delete
.OptionButtons.Delete
End With
For Each myCell In myRange
With myCell.Resize(1, maxBtns)
Set grpBox = wks.GroupBoxes.Add _
(Top:=.Top, Left:=.Left, Height:=.Height, _
Width:=.Width)
With grpBox
.Caption = ""
.Visible = True 'False
End With
End With
For iCtr = 0 To maxBtns - 1
With myCell.Offset(0, iCtr)
Set optBtn = wks.OptionButtons.Add _
(Top:=.Top, Left:=.Left, Height:=.Height, _
Width:=.Width)
optBtn.Caption = ""
If iCtr = 0 Then
With myCell.Offset(0, -1)
optBtn.LinkedCell = .Address(external:=True)
'.NumberFormat = ";;;"
End With
End If
End With
Next iCtr
Next myCell

End Sub


If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Test this against a copy of your worksheet--just in case!
 
Back
Top