View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Macro for checkbox generation

with myCBX
.Placement = xlMoveAndSize
.LinkedCell = myCell.Address(external:=True)
.Caption = ""
.Name = "CBX_" & myCell.Address(0, 0)
End With

--
Regards,
Tom Ogilvy

"rmcveigh" wrote:


Hi all,

I'm not the most experienced of Excel users so please bear with me. I'm
looking to generate a macro (because I'm lazy) that will place about 500
checkboxes in a single column, row by row. It also needs to move and
resize according to the data in an adjacent cell (i.e. if the text next
to it is too large and wordwraps another line, the box must move with
it). One checkbox per row is what I'm getting at.

This is the code I'm currently using:
Dim myCBX As CheckBox
Dim myCell As Range

With ActiveSheet
.CheckBoxes.Delete 'nice for setting up
For Each myCell In ActiveSheet.Range("O13:O503").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

Please and thanks.


--
rmcveigh
------------------------------------------------------------------------
rmcveigh's Profile: http://www.excelforum.com/member.php...o&userid=37353
View this thread: http://www.excelforum.com/showthread...hreadid=571452