Align check boxes

  • Thread starter Thread starter edrachel
  • Start date Start date
E

edrachel

I have a lot of check boxes to put on a worksheet. Is there any way I
can get them to line up automatically? I want to put two check boxes
in each cell with a letter next to each. I have tried the copy and
paste but that did not work. When I pasted to another cell it came in
lower than the one I copied and yes, the cells are the same highth.
Made no sense. Any help will be appreciated. Thanks.
 
If the checkboxes are already there, you can show the drawing toolbar.

Then click on the Arrow icon.
Select the left hand checkboxes
then click on the Draw icon on that Drawing toolbar
Then click on Align or Distribute
and align them where you want.

Then do the right hand checkboxes.

Personally, I think I'd align the checkboxes to cells with a macro that actually
added the checkboxes.

I'm not sure how you get the letters that go next to each, but this adds
checkboxes from the Forms toolbar to G2:H21 (20 checkboxes per column)

Option Explicit
Sub testme()

Dim myCBX As CheckBox
Dim myCell As Range
Dim myRng As Range

With ActiveSheet
Set myRng = .Range("G2:G21")
.CheckBoxes.Delete 'nice for setting up
'resize to two columns
For Each myCell In myRng.Resize(, 2).Cells
With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Address(external:=True)
.Caption = ""
.Name = "CBX_" & myCell.Address(0, 0)
End With
.NumberFormat = ";;;"
End With

Next myCell
End With
End Sub

Are you sure you shouldn't be using optionbuttons? If you can only select one
of these "checkboxes" per row, then OptionButtons may make your life simpler.

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

You may be able to steal something from Debra Dalgleish's site if you need
Optionbuttons (also from the Forms toolbar):

http://www.contextures.com/xlform01.html
 

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

Back
Top