ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   adding checkboxes (https://www.excelbanter.com/excel-programming/361718-adding-checkboxes.html)

shadespool

adding checkboxes
 

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....


--
shadespool
------------------------------------------------------------------------
shadespool's Profile: http://www.excelforum.com/member.php...o&userid=34537
View this thread: http://www.excelforum.com/showthread...hreadid=542970


Tom Ogilvy

adding checkboxes
 
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

--
Regards,
Tom Ogilvy


"shadespool" wrote:


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....


--
shadespool
------------------------------------------------------------------------
shadespool's Profile: http://www.excelforum.com/member.php...o&userid=34537
View this thread: http://www.excelforum.com/showthread...hreadid=542970



shadespool[_2_]

adding checkboxes
 

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.
:

--
shadespoo
-----------------------------------------------------------------------
shadespool's Profile: http://www.excelforum.com/member.php...fo&userid=3453
View this thread: http://www.excelforum.com/showthread.php?threadid=54297



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com