Option Buttons in a Form

I

Idaho Word Man

I am a beginner in Excel, so don't get mad if my questions are rather basic.
I've searched through previous posts, but I haven't been able to find answers
to these questions.

I'm trying to create a form in Excel with 42 yes/no questions. I used pairs
of Option Buttons from the Forms toolbar for each question. I have placed a
group box around each pair and I have used Ctrl-Click and then Group to group
each pair into a group box. The buttons seem to work OK, so I'm feeling
pretty good so far.

Here are my questions:

1. Is there a way to get rid of the lines and labels on the group boxes?
I've tried Format Object - Colors and Lines, and I've tried No Line and I've
tried a white line, but they still have a line around them. How do you get
rid of the lines?

2. Is there a way to make the group boxes exactly the same size so I can
align my buttons evenly? My group boxes don't snap to a grid, and I have to
draw each one by hand, so they're all a little different, and the buttons are
aligned within each box a little different. I've tried copying and pasting a
box, but the pasted box has the same number as the original.

3. Is there a way to unselect a button if I accidentally click on it? I
want the default value of all of them to be unclicked when the user opens the
form, but if I accidentally click one, it seems to be clicked forever.

4. Is there any way to set the font or font size on the labels for the
buttons?

I'm using Windows XP Professional with Office 2003.

Thanks in advance for any help you can provide.

Fred
 
R

Rick Rothstein \(MVP - VB\)

When you say "form", you mean a UserForm, correct? The OptionButtons you put
on a UserForm have a GroupName property which you can use to group the them
rather than put them into a GroupBox. Just select the OptionButtons you want
to be grouped and give them the same GroupName. Do the same thing for the
other OptionButtons. Now you can select a column of OptionButtons (say, all
the Yes ones), then click on Format/Align/Lefts in the VB editor's menu bar.
Do the same for the No OptionButtons. You can then select a pair of Yes/No
OptionButtons and click on Format/Align/Bottoms in the menu bar to line
them. As for the font size, assuming you want the font size to be the same
for all of them, select all of the OptionButtons and click on Font in the
Properties window (click F4 if it isn't showing), then click on the button
with 3 dots that appears and pick the font properties you want them all to
have from the dialog box that appeared. Finally, you can unselect and
individual OptionButton by setting its Value property to False in code. For
example...

OptionButton1.Vaue = False

Rick
 
R

Rick Rothstein \(MVP - VB\)

OptionButton1.Vaue = False

Mistyping... that should be

OptionButton1.Value = False

Rick
 
I

Idaho Word Man

When I said I was a beginner, I meant it.

Is this a UserForm? I don't have any idea. I did not create this document --
I inherited it. Its name is Form-1687-Rev3A.xls. Does that make it a UserForm?

You say I can "give them the same GroupName." How do I do that?

You say I can set an option button's property to False "in code." How do I
do that? What kind of "code" are you talking about. I'm a beginner in Excel.
 
D

Dave Peterson

How about an alternative?

Instead of using a bunch of optionbuttons (in pairs in groupboxes), couldn't you
use a single checkbox to replace the pair of optionbuttons. If it's checked,
then it's yes. If it's not checked then it's no.

========
From your description, you're using a worksheet and making it look like a form
to the user. This is different from a UserForm. (Rick missed this when he read
your original post.)

UserForms look like the builtin dialogs that you see in excel--like when you use
Tools|Options.

========
#1. You can hide the groupboxes, but you need to use code.

If you don't want to use checkboxes instead of pairs of optionbuttons, then you
can do this:
Select the worksheet with the optionbuttons (and groupboxes)
Hit alt-f11 to get to the VBE (where macros and UserForms live)
hit ctrl-g to see the immediate window
Type this and hit enter
activesheet.groupboxes.visible = false

When you want to see them again, do the same thing, but change that False to
True.
Then close the VBE window and go back to excel to see if it worked ok.

#2. You can actually use code to locate the optionbuttons and groupboxes so
that they're aligned nicely.

But you can also hit and hold the alt key while you position the groupboxes.
They'll snap-to the cell borders.

You can also select the groupboxes (click on the first and ctrl-click on the
others), then show the Drawing toolbar.

Click on the Draw dropdown and choose align/nudge and other shape adjustment
stuff.

#3. You can use code to turn off each option button, but maybe defaulting to No
(or yes) would be better. That way the user can "skip" the questions that don't
change.

#4. You used the buttons from that same Forms toolbar, right?
You can select the text in the button and use formatting buttons (font size/font
color) for the selected text. Yep, you can change formatting for individual
characters.

=======
This kind of sounds like a survey form you're making.

You may want to look at this page on Debra Dalgleish's site:
http://contextures.com/xlForm01.html

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

Idaho Word Man

I finally figured out how to make my form work, and all the stuff about code
and groupboxes is a bunch of crap.

First of all, you don't want to use the option buttons from the Forms
toolbar; use the option buttons from the Control Toolbox.

Then, when you've put the option buttons where you want them and you're
ready to group them, right-click on a button and select Properties. In the
Properties window that opens, type in an appropriate GroupName. Any buttons
that are given the same GroupName will work together so that only one button
of that group can be selected. It doesn't matter how many buttons you have in
a group or where they are on the form -- you can only select one button in
each group.

If you inadvertently click on a button and want to uncheck it, go back to
the same Properties window and set the Value to False. That unclicks it. If
you want it clicked, set the Value to True.

If you do it that way, you don't need groupboxes, you don't need to write
fancy code, you don't need to worry about whether the borders show, etc.

I hope this saves somebody some time. Heaven knows how much time I wasted
trying to figure it out.

Fred
 
D

Dave Peterson

First, glad you got your stuff to work.

But personally, I like the controls from the Forms toolbar as opposed to the
controls from the Control toolbox toolbar.

In lots of cases, the Forms controls are much better behaved than the Control
toolbox controls.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top