Add checkbox in cells

paddydive

Active Member
Joined
Jun 30, 2010
Messages
460
Hi,

I have below code to add checkboxes in cell F1 to F5, the code works perfectly but it does not align the checkboxes.
HTML:
Sub de()
Dim chkbx As CheckBox
i = 1
For Each cell In Range("F1:F5")
    Set chkbx = ActiveSheet.CheckBoxes.Add(cell.Left, cell.Top, cell.Height, cell.Width)
    With chkbx
        .Caption = "Day" & i
    End With
i = i + 1
Next
End Sub

Please help, i want these checkboxes to fit properly in cells, but now they are overlapping on another.
 
Last edited:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try...

Code:
Set chkbx = ActiveSheet.CheckBoxes.Add(cell.Left, cell.Top, cell.Width, cell.Height)
 
Upvote 0
Thanks Domenic,

Was it just bcoz I changed the sequance of width and Height ?

Will appreciate help for one more thing... which preferance should i choose in option preferances so that i can view the auto suggestions for activex and form control object. currently my machine does not show the intellisense for these objects like dropdown, checkboxes etc.
 
Upvote 0
Thanks Domenic,

You're very welcome!

Was it just bcoz I changed the sequance of width and Height ?

Yes.

Will appreciate help for one more thing... which preferance should i choose in option preferances so that i can view the auto suggestions for activex and form control object. currently my machine does not show the intellisense for these objects like dropdown, checkboxes etc.

Have a look here...

http://www.tushar-mehta.com/excel/vba/vba-embedded or linked objects.htm
 
Upvote 0
Thanks again.... :-(

But it was not mentioned there, i want to know which Object library should be active in Tools Preferances to show intellisense for activex and form control objects.
 
Upvote 0
Forms controls reference the Microsoft Excel Object Library. These controls are native to Excel, and the reference is automatically set by default. This reference cannot be removed.

ActiveX controls reference the Microsoft Forms Object Library. Note that this reference is automatically established by Excel once a control is inserted into a worksheet or userform.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top