adding checkboxes

S

shadespool

I am trying to insert checkboxes into a specific cell range of cells. I
have a loop to process each cell in turn and then add the cb.


Code:
--------------------

LeftPosition = ActiveCell.Left
TopPosition = ActiveCell.Top
ActiveSheet.CheckBoxes.Add(LeftPosition, TopPosition, 25, 17.25).Select
Selection.Characters.Text = ""
With Selection
.Value = xlOff
.LinkedCell = CheckBoxLink
.Display3DShading = False
End With

--------------------


The loop processes the cells and adds the checkboxes successfully (1000
rows) but the further down the page it gets the checkboxes become
unaligned to the cell that it should be inserted into.

I thought that the checkbox could be inserted into the cell using the
top and left parameters of the cell, but I'm getting very frustrated
with this now !

Any suggestions welcome.Thanks....
 
G

Guest

Maybe something like this:

Sub AddBoxes()
Dim cell As Range
Dim cBox As CheckBox
For Each cell In Range("A2:A100")

Set cBox = ActiveSheet.CheckBoxes.Add( _
cell.Left, _
cell.Top, 25, 17.25)
cell.EntireRow.RowHeight = 17.25
cBox.Caption = ""
cBox.Value = xlOff
cBox.LinkedCell = cell.Address(external:=True)
cBox.Display3DShading = False
Next
End Sub
 
S

shadespool

Tom,

many thanks,
There seems to be a relation with the minimum size of the checkbo
(17.25). The mising link was to set the row height to the same heigh
as the checkbox.
:
 

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